block: fix bd_holder_dir kobject_create_and_add() error handling
PATCH 1/1 block: fix bd_holder_dir kobject_create_and_add() error handling
Commit 83cbce957446 ("block: add error handling for device_add_disk / add_disk") added error handling to device_add_disk(), however the goto label for the bd_holder_dir kobject_create_and_add() failure did not set the return value correctly, and so we can end up in a situation where kobject_create_and_add() fails but we report success.
--- block/genhd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/genhd.c +3 -1
@@ -472,8 +472,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, disk->part0->bd_holder_dir =kobject_create_and_add ("holders" , &ddev->kobj); -if (!disk->part0->bd_holder_dir) +if (!disk->part0->bd_holder_dir) { + ret = -ENOMEM ; goto out_del_integrity; + } disk->slave_dir =kobject_create_and_add ("slaves" , &ddev->kobj);if (!disk->slave_dir) { ret = -ENOMEM ;
Signature · 1 line
2.33.0
Jens Axboe
maintainerQuoted 5 lines · Luis Chamberlain
Commit
83cbce957446("block: add error handling fordevice_add_disk/add_disk") added error handling todevice_add_disk(), however the goto label for thebd_holder_dirkobject_create_and_add()failure did not set the return value correctly, and so we can end up in a situation wherekobject_create_and_add()fails but we report success.
I'm just going to fold this one in, as it's top-of-tree.
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jens Axboe
Quoted 5 lines · Luis Chamberlain
Commit
83cbce957446("block: add error handling fordevice_add_disk/add_disk") added error handling todevice_add_disk(), however the goto label for thebd_holder_dirkobject_create_and_add()failure did not set the return value correctly, and so we can end up in a situation wherekobject_create_and_add()fails but we report success.I'm just going to fold this one in, as it's top-of-tree.
Makes sense.
Luis