Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
block: grab a device refcount in disk_uevent
Browse files Browse the repository at this point in the history
Sending uevents requires the struct device to be alive.  To
ensure that grab the device refcount instead of just an inode
reference.

Fixes: bc359d0 ("block: add a disk_uevent helper")
Signed-off-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jul 1, 2021
1 parent 2b7a8dc commit 498dcc1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 498dcc1

Please sign in to comment.