Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75f8ee8e authored by Alan Stern's avatar Alan Stern Committed by James Bottomley
Browse files

[SCSI] fix memory leak in scsi_report_lun_scan



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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 277e76f1
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -1339,9 +1339,11 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
		sdev = scsi_alloc_sdev(starget, 0, NULL);
		sdev = scsi_alloc_sdev(starget, 0, NULL);
		if (!sdev)
		if (!sdev)
			return 0;
			return 0;
		if (scsi_device_get(sdev))
		if (scsi_device_get(sdev)) {
			__scsi_remove_device(sdev);
			return 0;
			return 0;
		}
		}
	}


	sprintf(devname, "host %d channel %d id %d",
	sprintf(devname, "host %d channel %d id %d",
		shost->host_no, sdev->channel, sdev->id);
		shost->host_no, sdev->channel, sdev->id);