mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 17:22:07 +00:00
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: bc359d03c7
("block: add a disk_uevent helper")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210701081638.246552-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2b7a8dc06d
commit
498dcc13fd
@ -365,12 +365,12 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action)
|
||||
xa_for_each(&disk->part_tbl, idx, part) {
|
||||
if (bdev_is_partition(part) && !bdev_nr_sectors(part))
|
||||
continue;
|
||||
if (!bdgrab(part))
|
||||
if (!kobject_get_unless_zero(&part->bd_device.kobj))
|
||||
continue;
|
||||
|
||||
rcu_read_unlock();
|
||||
kobject_uevent(bdev_kobj(part), action);
|
||||
bdput(part);
|
||||
put_device(&part->bd_device);
|
||||
rcu_read_lock();
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user