Skip to content

Commit 262152e

Browse files
Yang Xiuweigregkh
authored andcommitted
scsi: sd: fix missing put_disk() when device_add(&disk_dev) fails
commit 1e111c4 upstream. If device_add(&sdkp->disk_dev) fails, put_device() runs scsi_disk_release(), which frees the scsi_disk but leaves the gendisk referenced. The device_add_disk() error path in sd_probe() calls put_disk(gd); call put_disk(gd) here to mirror that cleanup. Fixes: 265dfe8 ("scsi: sd: Free scsi_disk device via put_device()") Cc: stable@vger.kernel.org Reviewed-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn> Link: https://patch.msgid.link/20260330014952.152776-1-yangxiuwei@kylinos.cn Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8a1fc8d commit 262152e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/scsi/sd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,6 +3727,7 @@ static int sd_probe(struct device *dev)
37273727
error = device_add(&sdkp->disk_dev);
37283728
if (error) {
37293729
put_device(&sdkp->disk_dev);
3730+
put_disk(gd);
37303731
goto out;
37313732
}
37323733

0 commit comments

Comments
 (0)