aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2018-03-19 10:53:50 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-19 08:55:10 +0200
commita8ce442c67ffcb33ad2555256c064b9dcee3e07e (patch)
tree6fc7c71d9409a0b9e8d98b6a4c1c35589e944fb3
parentc5f1f15ab5f1ca062b36b0188fc184d66d00fa89 (diff)
downloadlinux-yocto-a8ce442c67ffcb33ad2555256c064b9dcee3e07e.tar.gz
linux-yocto-a8ce442c67ffcb33ad2555256c064b9dcee3e07e.tar.bz2
linux-yocto-a8ce442c67ffcb33ad2555256c064b9dcee3e07e.zip
nvme: Skip checking heads without namespaces
commit 2079699c10c8c60a9572540c2f77d045abf036eb upstream. 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 <X>". 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 <Alex_Gagniuc@Dellteam.com> Cc: stable@vger.kernel.org Signed-off-by: Keith Busch <keith.busch@intel.com> Reviewed-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/nvme/host/core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 935593032123..bbe69e147b48 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2720,6 +2720,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;
}