Skip to content

Commit 498dcc1

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: bc359d0 ("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>
1 parent 2b7a8dc commit 498dcc1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

block/genhd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action)
365365
xa_for_each(&disk->part_tbl, idx, part) {
366366
if (bdev_is_partition(part) && !bdev_nr_sectors(part))
367367
continue;
368-
if (!bdgrab(part))
368+
if (!kobject_get_unless_zero(&part->bd_device.kobj))
369369
continue;
370370

371371
rcu_read_unlock();
372372
kobject_uevent(bdev_kobj(part), action);
373-
bdput(part);
373+
put_device(&part->bd_device);
374374
rcu_read_lock();
375375
}
376376
rcu_read_unlock();

0 commit comments

Comments
 (0)