This is a note to let you know that I've just added the patch titled scsi: sd: Unregister device if device_add_disk() failed in sd_probe() to the 6.8-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: scsi-sd-unregister-device-if-device_add_disk-failed-.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 0c9a43a52931f8460e098912e7b8427927783122 Author: Li Nan <linan122@xxxxxxxxxx> Date: Fri Dec 8 16:23:35 2023 +0800 scsi: sd: Unregister device if device_add_disk() failed in sd_probe() [ Upstream commit 0296bea01cfa6526be6bd2d16dc83b4e7f1af91f ] "if device_add() succeeds, you should call device_del() when you want to get rid of it." In sd_probe(), device_add_disk() fails when device_add() has already succeeded, so change put_device() to device_unregister() to ensure device resources are released. Fixes: 2a7a891f4c40 ("scsi: sd: Add error handling support for add_disk()") Signed-off-by: Li Nan <linan122@xxxxxxxxxx> Link: https://lore.kernel.org/r/20231208082335.1754205-1-linan666@xxxxxxxxxxxxxxx Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx> Reviewed-by: Yu Kuai <yukuai3@xxxxxxxxxx> Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index d5d3eea006c13..35200a7a73553 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3757,7 +3757,7 @@ static int sd_probe(struct device *dev) error = device_add_disk(dev, gd, NULL); if (error) { - put_device(&sdkp->disk_dev); + device_unregister(&sdkp->disk_dev); put_disk(gd); goto out; }