nvme: release namespace head reference on error
authorKeith Busch <kbusch@kernel.org>
Thu, 9 Apr 2020 16:09:00 +0000 (09:09 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Mar 2021 16:03:57 +0000 (17:03 +0100)
commit ac262508daa88fb12c5dc53cf30bde163f9f26c9 upstream.

If a namespace identification does not match the subsystem's head for
that NSID, release the reference that was taken when the matching head
was initially found.

Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvme/host/core.c

index 95d933bfd15bb0c8521ea8c695e0bc4d813c3d24..e4e24e7bf46288bea4cd582cd69ab451e74c6dd1 100644 (file)
@@ -3467,6 +3467,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
                                "IDs don't match for shared namespace %d\n",
                                        nsid);
                        ret = -EINVAL;
+                       nvme_put_ns_head(head);
                        goto out_unlock;
                }
        }