提交 498dcc13 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

block: grab a device refcount in disk_uevent

Sending uevents requires the struct device to be alive.  To
ensure that grab the device refcount instead of just an inode
reference.

Fixes: bc359d03 ("block: add a disk_uevent helper")
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210701081638.246552-2-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 2b7a8dc0
...@@ -365,12 +365,12 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action) ...@@ -365,12 +365,12 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action)
xa_for_each(&disk->part_tbl, idx, part) { xa_for_each(&disk->part_tbl, idx, part) {
if (bdev_is_partition(part) && !bdev_nr_sectors(part)) if (bdev_is_partition(part) && !bdev_nr_sectors(part))
continue; continue;
if (!bdgrab(part)) if (!kobject_get_unless_zero(&part->bd_device.kobj))
continue; continue;
rcu_read_unlock(); rcu_read_unlock();
kobject_uevent(bdev_kobj(part), action); kobject_uevent(bdev_kobj(part), action);
bdput(part); put_device(&part->bd_device);
rcu_read_lock(); rcu_read_lock();
} }
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册