]> Git Repo - J-linux.git/commitdiff
scsi: sd: Unregister device if device_add_disk() failed in sd_probe()
authorLi Nan <[email protected]>
Fri, 8 Dec 2023 08:23:35 +0000 (16:23 +0800)
committerMartin K. Petersen <[email protected]>
Tue, 2 Apr 2024 01:26:16 +0000 (21:26 -0400)
"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 <[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]>
drivers/scsi/sd.c

index 3cf89867029044ede7b2f6a844dca974b8d50e32..58fdf679341dc64ee1768f1d09dc7ce4d549b4bd 100644 (file)
@@ -3920,7 +3920,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;
        }
This page took 0.060233 seconds and 4 git commands to generate.