From: Keith Busch Date: Mon, 19 Mar 2018 16:53:50 +0000 (-0600) Subject: nvme: Skip checking heads without namespaces X-Git-Tag: v4.17-rc1~113^2~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2079699c10c8c60a9572540c2f77d045abf036eb;p=thirdparty%2Fkernel%2Flinux.git nvme: Skip checking heads without namespaces If a task is holding a reference to a namespace on a removed controller, the head will not be released. If the same controller is added again later, its namespaces may not be successfully added. Instead, the user will see kernel message "Duplicate IDs for nsid ". This patch fixes that by skipping heads that don't have namespaces when considering if a new namespace is safe to add. Reported-by: Alex Gagniuc Cc: stable@vger.kernel.org Signed-off-by: Keith Busch Reviewed-by: Max Gurtovoy Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f29a07ef122f1..7811b4886e63f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2809,6 +2809,7 @@ static int __nvme_check_ids(struct nvme_subsystem *subsys, list_for_each_entry(h, &subsys->nsheads, entry) { if (nvme_ns_ids_valid(&new->ids) && + !list_empty(&h->list) && nvme_ns_ids_equal(&new->ids, &h->ids)) return -EINVAL; }