From: Alan Stern Date: Fri, 12 Feb 2010 17:13:31 +0000 (-0500) Subject: fix memory leak in scsi_report_lun_scan X-Git-Tag: v2.6.33.15~36 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=578aa9eecba99df4190c9cdb11fe7b7f410b7745;p=karo-tx-linux.git fix memory leak in scsi_report_lun_scan commit 75f8ee8e01a6c96652f27da40d4bdac9e2e485f0 upstream. 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 Signed-off-by: James Bottomley Cc: Hannes Reinecke Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 012f73a96880..60b262d66b5b 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -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",