Skip to content

Commit d52987b

Browse files
jankaraaxboe
authored andcommitted
genhd: Fix leaked module reference for NVME devices
Commit 8ddcd65 "block: introduce GENHD_FL_HIDDEN" added handling of hidden devices to get_gendisk() but forgot to drop module reference which is also acquired by get_disk(). Drop the reference as necessary. Arguably the function naming here is misleading as put_disk() is *not* the counterpart of get_disk() but let's fix that in the follow up commit since that will be more intrusive. Fixes: 8ddcd65 CC: Christoph Hellwig <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d9c10e5 commit d52987b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/genhd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,10 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
817817
}
818818

819819
if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) {
820+
struct module *owner = disk->fops->owner;
821+
820822
put_disk(disk);
823+
module_put(owner);
821824
disk = NULL;
822825
}
823826
return disk;

0 commit comments

Comments
 (0)