Commit 0f5197ea authored by Keith Busch's avatar Keith Busch
Browse files

nvme-multipath: fix leak on try_module_get failure



We need to fall back to the synchronous removal if we can't get a
reference on the module needed for the deferred removal.

Fixes: 62188639 ("nvme-multipath: introduce delayed removal of the multipath head node")
Reviewed-by: default avatarNilay Shroff <nilay@linux.ibm.com>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent dd677d05
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -1310,13 +1310,11 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
	if (!list_empty(&head->list))
		goto out;

	if (head->delayed_removal_secs) {
	/*
	 * Ensure that no one could remove this module while the head
	 * remove work is pending.
	 */
		if (!try_module_get(THIS_MODULE))
			goto out;
	if (head->delayed_removal_secs && try_module_get(THIS_MODULE)) {
		mod_delayed_work(nvme_wq, &head->remove_work,
				head->delayed_removal_secs * HZ);
	} else {