block: Fixup condition detecting exclusive opener during partition rescan
Subsystems (2)
PATCH 1/1 block: Fixup condition detecting exclusive opener during partition rescan
The condition detecting whether somebody else has the device exclusively open in disk_scan_partitions() has a brownpaper bag bug. It triggers also when nobody has the device exclusively open and we are coming from BLKRRPART path. Interestingly this didn't have any adverse effects during testing because tools update kernel's notion of the partition table using ioctls and don't rely on BLKRRPART. Fix the bug before somebody trips over it.
--- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +1 -1
@@ -367,7 +367,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner)if (disk->open_partitions)return -EBUSY ;/* Someone else has bdev exclusively open? */ -if (disk->part0->bd_holder != owner) +if (disk->part0->bd_holder && disk->part0->bd_holder != owner)return -EBUSY ;set_bit (GD_NEED_PART_SCAN , &disk->state);
Signature · 1 line
2.35.3
Jens Axboe
maintainerQuoted 7 lines · Jan Kara
The condition detecting whether somebody else has the device exclusively open in
disk_scan_partitions()has a brownpaper bag bug. It triggers also when nobody has the device exclusively open and we are coming from BLKRRPART path. Interestingly this didn't have any adverse effects during testing because tools update kernel's notion of the partition table using ioctls and don't rely on BLKRRPART. Fix the bug before somebody trips over it.
I folded this in. It's funny because I did consider this when reviewing it, but then convinced myself it was fine...
Signature · 1 line
Jens Axboe