Skip to content

Commit

Permalink
[SCSI] fix memory leak in scsi_report_lun_scan
Browse files Browse the repository at this point in the history
This patch (as1333) fixes a bug in scsi_report_lun_scan().  If a
newly-allocated device can't be used, it should be deleted.

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 Feb 18, 2010
1 parent 277e76f commit 75f8ee8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/scsi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,10 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
sdev = scsi_alloc_sdev(starget, 0, NULL);
if (!sdev)
return 0;
if (scsi_device_get(sdev))
if (scsi_device_get(sdev)) {
__scsi_remove_device(sdev);
return 0;
}
}

sprintf(devname, "host %d channel %d id %d",
Expand Down

0 comments on commit 75f8ee8

Please sign in to comment.