Re: [PATCH] scsi: sd: unregister device if device_add_disk() failed in sd_probe()

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

 



+CC Christoph Hellwig
+CC Bart Van Assche
在 2023/12/08 16:23, linan666@xxxxxxxxxxxxxxx 写道:
From: Li Nan <linan122@xxxxxxxxxx>

"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.

I was shocked that this patch is still there. This patch is easy and
straightforward.

LGTM
Reviewed-by: Yu Kuai <yukuai3@xxxxxxxxxx>

BTW, Nan, it will be better if you have a reporducer for this.

Fixes: 2a7a891f4c40 ("scsi: sd: Add error handling support for add_disk()")
Signed-off-by: Li Nan <linan122@xxxxxxxxxx>
---
  drivers/scsi/sd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 542a4bbb21bc..d81cbeee06eb 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3736,7 +3736,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;
  	}






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux