Skip to content

Commit

Permalink
11969 Attempting to attach an invalid nvme namespace will cause a panic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hrosenfeld authored and Dan McDonald committed Mar 30, 2021
1 parent 472cd20 commit ed0a9ca
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions usr/src/uts/common/io/nvme/nvme.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ed0a9ca

Please sign in to comment.