提交 d52987b5 编写于 作者: J Jan Kara 提交者: Jens Axboe

genhd: Fix leaked module reference for NVME devices

Commit 8ddcd653 "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: 8ddcd653
CC: Christoph Hellwig <hch@lst.de>
Signed-off-by: NJan Kara <jack@suse.cz>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 d9c10e5b
...@@ -817,7 +817,10 @@ struct gendisk *get_gendisk(dev_t devt, int *partno) ...@@ -817,7 +817,10 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
} }
if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) { if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) {
struct module *owner = disk->fops->owner;
put_disk(disk); put_disk(disk);
module_put(owner);
disk = NULL; disk = NULL;
} }
return disk; return disk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册