[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 <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
This commit is contained in:
Alan Stern 2010-03-18 15:41:22 -04:00 committed by James Bottomley
parent 1821438a9b
commit 12fb8c1574
1 changed files with 1 additions and 2 deletions

View File

@ -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