Patch "block: fix device_add_disk() kobject_create_and_add() error handling" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    block: fix device_add_disk() kobject_create_and_add() error handling

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     block-fix-device_add_disk-kobject_create_and_add-err.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 651a980e22c8eaa47a09837733cbf14337d4a26e
Author: Luis Chamberlain <mcgrof@xxxxxxxxxx>
Date:   Wed Nov 3 09:40:23 2021 -0700

    block: fix device_add_disk() kobject_create_and_add() error handling
    
    [ Upstream commit fe7d064fa3faec5d8157029fb8720b4fddc9e1e8 ]
    
    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 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: 83cbce957446 ("block: add error handling for device_add_disk / add_disk")
    Reported-by: kernel test robot <lkp@xxxxxxxxx>
    Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Link: https://lore.kernel.org/r/20211103164023.1384821-1-mcgrof@xxxxxxxxxx
    [axboe: fold in followup fix from Wu Bo <wubo40@xxxxxxxxxx>]
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/genhd.c b/block/genhd.c
index ab12ae6e636e8..6accd0b185e9e 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -467,11 +467,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)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux