Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] nvme: fix srcu locking on error return in nvme_get_ns_from_disk
@ 2019-05-17  9:47 Christoph Hellwig
  2019-05-17  9:47 ` [PATCH 2/4] nvme: remove the ifdef around nvme_nvm_ioctl Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-05-17  9:47 UTC (permalink / raw)


If we can't get a namespace don't leak the SRCU lock.  nvme_ioctl was
working around this, but nvme_pr_command wasn't handling this properly.
Just do what callers would usually expect.

Signed-off-by: Christoph Hellwig <hch at lst.de>
Reviewed-by: Keith Busch <keith.busch at intel.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/host/core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7da80f375315..63146060df66 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1361,9 +1361,14 @@ static struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
 {
 #ifdef CONFIG_NVME_MULTIPATH
 	if (disk->fops == &nvme_ns_head_ops) {
+		struct nvme_ns *ns;
+
 		*head = disk->private_data;
 		*srcu_idx = srcu_read_lock(&(*head)->srcu);
-		return nvme_find_path(*head);
+		ns = nvme_find_path(*head);
+		if (!ns)
+			srcu_read_unlock(&(*head)->srcu, *srcu_idx);
+		return ns;
 	}
 #endif
 	*head = NULL;
@@ -1410,9 +1415,9 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
 
 	ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx);
 	if (unlikely(!ns))
-		ret = -EWOULDBLOCK;
-	else
-		ret = nvme_ns_ioctl(ns, cmd, arg);
+		return -EWOULDBLOCK;
+
+	ret = nvme_ns_ioctl(ns, cmd, arg);
 	nvme_put_ns_from_disk(head, srcu_idx);
 	return ret;
 }
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-05-17 18:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-17  9:47 [PATCH 1/4] nvme: fix srcu locking on error return in nvme_get_ns_from_disk Christoph Hellwig
2019-05-17  9:47 ` [PATCH 2/4] nvme: remove the ifdef around nvme_nvm_ioctl Christoph Hellwig
2019-05-17  9:47 ` [PATCH 3/4] nvme: merge nvme_ns_ioctl into nvme_ioctl Christoph Hellwig
2019-05-17 15:31   ` Minwoo Im
2019-05-17  9:47 ` [PATCH v2 4/4] nvme: release namespace SRCU protection before performing controller ioctls Christoph Hellwig
2019-05-17 14:41   ` Keith Busch
2019-05-17 16:30   ` Chaitanya Kulkarni
2019-05-17 18:36 ` [PATCH 1/4] nvme: fix srcu locking on error return in nvme_get_ns_from_disk Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox