From: Alan Stern Date: Thu, 18 Mar 2010 19:41:22 +0000 (-0400) Subject: [SCSI] don't kfree an initialized struct device X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=12fb8c1574d7d0c262d2f4c667047889c4f27ebe;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git [SCSI] don't kfree an initialized struct device This patch (as1359) fixes a bug in scsi_alloc_target(). After a device structure has been initialized (and especially after its name has been set), it must not be freed directly. One has to call put_device() instead. Signed-off-by: Alan Stern Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 38518b088073..c992ecf4e372 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -459,8 +459,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, found_target->reap_ref++; spin_unlock_irqrestore(shost->host_lock, flags); if (found_target->state != STARGET_DEL) { - put_device(parent); - kfree(starget); + put_device(dev); return found_target; } /* Unfortunately, we found a dying target; need to