mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
block: fix device_add_disk() kobject_create_and_add() error handling
Commit83cbce9574
("block: add error handling for device_add_disk / add_disk") added error handling to device_add_disk(), however the goto label for the 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. Fixes:83cbce9574
("block: add error handling for device_add_disk / add_disk") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20211103164023.1384821-1-mcgrof@kernel.org [axboe: fold in followup fix from Wu Bo <wubo40@huawei.com>] Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
10c4787015
commit
fe7d064fa3
@ -468,11 +468,15 @@ int 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)
|
||||
if (!disk->slave_dir) {
|
||||
ret = -ENOMEM;
|
||||
goto out_put_holder_dir;
|
||||
}
|
||||
|
||||
ret = bd_register_pending_holders(disk);
|
||||
if (ret < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user