summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2019-10-01 10:59:49 +0000
committermlelstv <mlelstv@NetBSD.org>2019-10-01 10:59:49 +0000
commitd27fc2c98ea725e751ccaa61d78797d76b0aed60 (patch)
tree8abaabf1367d531807793e1e5dcc4dee90638465 /sys/dev
parentc99d174da1c7ec7980895796661b63440e4fd762 (diff)
Don't attach an ld device if the format descriptor is unsupported/unused.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/ld_nvme.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/dev/ic/ld_nvme.c b/sys/dev/ic/ld_nvme.c
index c47e9eadcbb..38e7a56306c 100644
--- a/sys/dev/ic/ld_nvme.c
+++ b/sys/dev/ic/ld_nvme.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $ */
+/* $NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $ */
/*-
* Copyright (C) 2016 NONAKA Kimihiro <nonaka@netbsd.org>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -105,6 +105,19 @@ ld_nvme_attach(device_t parent, device_t self, void *aux)
KASSERT(ns);
f = &ns->ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+ /*
+ * NVME1.0e 6.11 Identify command
+ *
+ * LBADS values smaller than 9 are not supported, a value
+ * of zero means that the format is not used.
+ */
+ if (f->lbads < 9) {
+ if (f->lbads > 0)
+ aprint_error_dev(self,
+ "unsupported logical data size %u\n", f->lbads);
+ return;
+ }
+
ld->sc_secsize = 1 << f->lbads;
ld->sc_secperunit = ns->ident->nsze;
ld->sc_maxxfer = naa->naa_maxphys;