Commit 12fb8c15 authored by Alan Stern's avatar Alan Stern Committed by James Bottomley

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 1821438a
...@@ -459,8 +459,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, ...@@ -459,8 +459,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
found_target->reap_ref++; found_target->reap_ref++;
spin_unlock_irqrestore(shost->host_lock, flags); spin_unlock_irqrestore(shost->host_lock, flags);
if (found_target->state != STARGET_DEL) { if (found_target->state != STARGET_DEL) {
put_device(parent); put_device(dev);
kfree(starget);
return found_target; return found_target;
} }
/* Unfortunately, we found a dying target; need to /* Unfortunately, we found a dying target; need to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment