diff options
author | Christoph Hellwig <hch@lst.de> | 2021-07-01 10:16:37 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-07-01 18:21:24 +0200 |
commit | 498dcc13fd6463de29b94e160f40ed04d5477cd8 (patch) | |
tree | fac09e7780f90adc89db1d48fa7140a37e11af70 /block | |
parent | s390/dasd: Avoid field over-reading memcpy() (diff) | |
download | linux-498dcc13fd6463de29b94e160f40ed04d5477cd8.tar.xz linux-498dcc13fd6463de29b94e160f40ed04d5477cd8.zip |
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: bc359d03c7ec ("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>
Diffstat (limited to 'block')
-rw-r--r-- | block/genhd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/genhd.c b/block/genhd.c index 79aa40b4c39c..af4d2ab4a633 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -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(); |