Re: [PATCH] scsi: sd: Jump to out_free_index if device_add{,_disk}() fail

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

 



On marted? 29 marzo 2022 09:57:53 CEST Dan Carpenter wrote:
> On Tue, Mar 29, 2022 at 10:47:45AM +0300, Dan Carpenter wrote:
> > No, this patch is wrong.  That is supposed to be freed in scsi_disk_release()
> > but apparently that's not getting called.  Is the ref counting off?
> > 
> 
> Yeah.  The device_add() needs a matching device_del().
> 
> regards,
> dan carpenter
> 
Thanks, Dan.

I've just just checked other similar code and saw the following pattern 
whenever we have an error:

device_del(dev);
put_device(dev);

Therefore, I suppose that you are suggesting the following simple change:

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a390679cf458..13d96d0f9dde 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3474,6 +3474,7 @@ static int sd_probe(struct device *dev)
 
        error = device_add_disk(dev, gd, NULL);
        if (error) {
+               device_del(&sdkp->disk_dev);
                put_device(&sdkp->disk_dev);
                goto out;
        }

Did I get it?

Regards,

Fabio





[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