summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Rosenfeld <hans.rosenfeld@joyent.com>2019-09-09 18:04:22 +0000
committerDan McDonald <danmcd@joyent.com>2021-03-30 13:57:58 -0400
commited0a9ca2a3cceedc0e6e889472de1cec55ca2faf (patch)
treea35e64aacee75eaec53c1dc7cbff8171bd5bf4f5
parent472cd20d26008f77084ade4c2048159b98c2b705 (diff)
downloadillumos-joyent-ed0a9ca2a3cceedc0e6e889472de1cec55ca2faf.tar.gz
11969 Attempting to attach an invalid nvme namespace will cause a panic
Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Andy Fiddaman <andy@omnios.org> Reviewed by: Yuri Pankov <yuripv@yuripv.dev> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/uts/common/io/nvme/nvme.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/usr/src/uts/common/io/nvme/nvme.c b/usr/src/uts/common/io/nvme/nvme.c
index d1fa87c881..e37d0598c3 100644
--- a/usr/src/uts/common/io/nvme/nvme.c
+++ b/usr/src/uts/common/io/nvme/nvme.c
@@ -4550,6 +4550,9 @@ nvme_ioctl_detach(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, int mode,
if (nsid == 0)
return (EINVAL);
+ if (nvme->n_ns[nsid - 1].ns_ignore)
+ return (0);
+
rv = bd_detach_handle(nvme->n_ns[nsid - 1].ns_bd_hdl);
if (rv != DDI_SUCCESS)
rv = EBUSY;
@@ -4580,6 +4583,14 @@ nvme_ioctl_attach(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, int mode,
kmem_free(idns, sizeof (nvme_identify_nsid_t));
+ if (nvme->n_ns[nsid - 1].ns_ignore)
+ return (ENOTSUP);
+
+ if (nvme->n_ns[nsid - 1].ns_bd_hdl == NULL)
+ nvme->n_ns[nsid - 1].ns_bd_hdl = bd_alloc_handle(
+ &nvme->n_ns[nsid - 1], &nvme_bd_ops, &nvme->n_prp_dma_attr,
+ KM_SLEEP);
+
rv = bd_attach_handle(nvme->n_dip, nvme->n_ns[nsid - 1].ns_bd_hdl);
if (rv != DDI_SUCCESS)
rv = EBUSY;