From: Keith Busch Date: Thu, 9 Apr 2020 16:09:01 +0000 (-0700) Subject: nvme: always search for namespace head X-Git-Tag: v5.10.7~2495^2~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ad1927a3bc2735996ccc74e31b68a41ae9a3d33;p=platform%2Fkernel%2Flinux-rpi.git nvme: always search for namespace head Even if a namespace reports it is not capable of sharing, search the subsystem for a matching namespace head. If found, the driver should reject that namespace since it's coming from an invalid configuration. Signed-off-by: Keith Busch Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f2dc89d..6093c8b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3489,8 +3489,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, goto out; mutex_lock(&ctrl->subsys->lock); - if (is_shared) - head = nvme_find_ns_head(ctrl->subsys, nsid); + head = nvme_find_ns_head(ctrl->subsys, nsid); if (!head) { head = nvme_alloc_ns_head(ctrl, nsid, &ids); if (IS_ERR(head)) { @@ -3498,6 +3497,14 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, goto out_unlock; } } else { + if (!is_shared) { + dev_err(ctrl->device, + "Duplicate unshared namespace %d\n", + nsid); + ret = -EINVAL; + nvme_put_ns_head(head); + goto out_unlock; + } if (!nvme_ns_ids_equal(&head->ids, &ids)) { dev_err(ctrl->device, "IDs don't match for shared namespace %d\n",