Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] Fix refcount leak in scsi_report_lun_scan

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

Alan Stern and committed by
James Bottomley
2ef89198 34ea80ec

+5 -3
+5 -3
drivers/scsi/scsi_scan.c
··· 1074 1074 struct scsi_sense_hdr sshdr; 1075 1075 struct scsi_device *sdev; 1076 1076 struct Scsi_Host *shost = dev_to_shost(&starget->dev); 1077 + int ret = 0; 1077 1078 1078 1079 /* 1079 1080 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. ··· 1170 1169 /* 1171 1170 * The device probably does not support a REPORT LUN command 1172 1171 */ 1173 - kfree(lun_data); 1174 - return 1; 1172 + ret = 1; 1173 + goto out_err; 1175 1174 } 1176 1175 1177 1176 /* ··· 1239 1238 } 1240 1239 } 1241 1240 1241 + out_err: 1242 1242 kfree(lun_data); 1243 1243 out: 1244 1244 scsi_device_put(sdev); ··· 1248 1246 * the sdev we used didn't appear in the report luns scan 1249 1247 */ 1250 1248 scsi_destroy_sdev(sdev); 1251 - return 0; 1249 + return ret; 1252 1250 } 1253 1251 1254 1252 struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,