Skip to content

Commit 0f5197e

Browse files
committed
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: 6218863 ("nvme-multipath: introduce delayed removal of the multipath head node") Reviewed-by: Nilay Shroff <[email protected]> Reviewed-by: John Garry <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent dd677d0 commit 0f5197e

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

drivers/nvme/host/multipath.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,13 +1310,11 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
13101310
if (!list_empty(&head->list))
13111311
goto out;
13121312

1313-
if (head->delayed_removal_secs) {
1314-
/*
1315-
* Ensure that no one could remove this module while the head
1316-
* remove work is pending.
1317-
*/
1318-
if (!try_module_get(THIS_MODULE))
1319-
goto out;
1313+
/*
1314+
* Ensure that no one could remove this module while the head
1315+
* remove work is pending.
1316+
*/
1317+
if (head->delayed_removal_secs && try_module_get(THIS_MODULE)) {
13201318
mod_delayed_work(nvme_wq, &head->remove_work,
13211319
head->delayed_removal_secs * HZ);
13221320
} else {

0 commit comments

Comments
 (0)