summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2018-02-27 12:59:53 +0000
committerchristos <christos@NetBSD.org>2018-02-27 12:59:53 +0000
commit65de44d8f201ff2c57c2c14d809be8e3da6e34fe (patch)
tree77941874e18c5c4c64e9d9d17432615e7c5157fb /sys/dev
parent7aea4598f08c76dbec28e548266dd2e38ccdef28 (diff)
- don't leak ccb on alloc failure.
- KASSERT to prevent memory leak.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/nvme.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c
index 7feb342a3cb..cf7d551c446 100644
--- a/sys/dev/ic/nvme.c
+++ b/sys/dev/ic/nvme.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme.c,v 1.31 2017/10/28 04:53:55 riastradh Exp $ */
+/* $NetBSD: nvme.c,v 1.32 2018/02/27 12:59:53 christos Exp $ */
/* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.31 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.32 2018/02/27 12:59:53 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -570,8 +570,10 @@ nvme_ns_identify(struct nvme_softc *sc, uint16_t nsid)
KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
mem = nvme_dmamem_alloc(sc, sizeof(*identify));
- if (mem == NULL)
+ if (mem == NULL) {
+ nvme_ccb_put(sc->sc_admin_q, ccb);
return ENOMEM;
+ }
memset(&sqe, 0, sizeof(sqe));
sqe.opcode = NVM_ADMIN_IDENTIFY;
@@ -601,6 +603,7 @@ nvme_ns_identify(struct nvme_softc *sc, uint16_t nsid)
ns = nvme_ns_get(sc, nsid);
KASSERT(ns);
+ KASSERT(ns->ident == NULL);
ns->ident = identify;
done: