-/* $OpenBSD: nvme.c,v 1.90 2021/02/09 01:50:10 jmatthew Exp $ */
+/* $OpenBSD: nvme.c,v 1.91 2021/02/25 07:30:36 jan Exp $ */
/*
* Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
scsi_io_put(&sc->sc_iopool, ccb);
identify = NVME_DMA_KVA(mem);
- if (rv == 0 && lemtoh64(&identify->nsze) > 0) {
- /* Commit namespace if it has a size greater than zero. */
- identify = malloc(sizeof(*identify), M_DEVBUF, M_WAITOK);
- memcpy(identify, NVME_DMA_KVA(mem), sizeof(*identify));
- sc->sc_namespaces[link->target].ident = identify;
+ if (rv == 0) {
+ if (lemtoh64(&identify->nsze) > 0) {
+ /* Commit namespace if it has a size greater than zero. */
+ identify = malloc(sizeof(*identify), M_DEVBUF, M_WAITOK);
+ memcpy(identify, NVME_DMA_KVA(mem), sizeof(*identify));
+ sc->sc_namespaces[link->target].ident = identify;
+ } else {
+ /* Don't attach a namespace if its size is zero. */
+ rv = ENXIO;
+ }
}
nvme_dmamem_free(sc, mem);