A bug in scsi_alloc_target of drivers/scsi/scsi_scan.c

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

 



When debugging a race condition in scsi_remove_target of 3.12, I ran into this possible bug within scsi_alloc_target.
When an existing "struct scsi_target" is found and used, the starget just got through kzmalloc should be freed, rather than dong a "put_device(dev)".

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 81d4151..96795d4 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -483,7 +483,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,

        spin_unlock_irqrestore(shost->host_lock, flags);
        if (ref_got) {
-               put_device(dev);
+               kfree(starget);
                return found_target;
        }
        /*
--

Dashi Cao




[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