Skip to content

Commit 0296bea

Browse files
Li Nanmartinkpetersen
authored andcommitted
scsi: sd: Unregister device if device_add_disk() failed in sd_probe()
"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: 2a7a891 ("scsi: sd: Add error handling support for add_disk()") Signed-off-by: Li Nan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6bc5e70 commit 0296bea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3920,7 +3920,7 @@ static int sd_probe(struct device *dev)
39203920

39213921
error = device_add_disk(dev, gd, NULL);
39223922
if (error) {
3923-
put_device(&sdkp->disk_dev);
3923+
device_unregister(&sdkp->disk_dev);
39243924
put_disk(gd);
39253925
goto out;
39263926
}

0 commit comments

Comments
 (0)