Skip to content

Commit

Permalink
[SCSI] don't kfree an initialized struct device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alan Stern authored and James Bottomley committed Apr 11, 2010
1 parent 1821438 commit 12fb8c1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/scsi/scsi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 12fb8c1

Please sign in to comment.