aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2006-02-05 10:01:33 -0500
committer <jejb@mulgrave.il.steeleye.com>2006-02-27 23:55:07 -0500
commita97a83a06b44d4d1cb01191423caf9813a150b95 (patch)
treef74949bd8b8374036d19947b43f3e6d239eb5710 /drivers
parent1acc0b0ba409dcf4909890fb33e0829f7fd400be (diff)
[SCSI] fix uninitialized variable error
in __scsi_add_device, sdev may be uninitialised if scsi_host_scan_allowed() returns false. Fix by initialising at the top of the routine. Also rely on the fact that scsi_probe_and_add_lun() only actually fills in the sdev pointer if the SCSI_SCAN_LUN_PRESENT case (so no need to check the return value). Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_scan.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index dfdbbd008630..803c7b9690c5 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1243,9 +1243,8 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1243struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, 1243struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
1244 uint id, uint lun, void *hostdata) 1244 uint id, uint lun, void *hostdata)
1245{ 1245{
1246 struct scsi_device *sdev; 1246 struct scsi_device *sdev = ERR_PTR(-ENODEV);
1247 struct device *parent = &shost->shost_gendev; 1247 struct device *parent = &shost->shost_gendev;
1248 int res;
1249 struct scsi_target *starget; 1248 struct scsi_target *starget;
1250 1249
1251 starget = scsi_alloc_target(parent, channel, id); 1250 starget = scsi_alloc_target(parent, channel, id);
@@ -1254,12 +1253,8 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
1254 1253
1255 get_device(&starget->dev); 1254 get_device(&starget->dev);
1256 mutex_lock(&shost->scan_mutex); 1255 mutex_lock(&shost->scan_mutex);
1257 if (scsi_host_scan_allowed(shost)) { 1256 if (scsi_host_scan_allowed(shost))
1258 res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, 1257 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
1259 hostdata);
1260 if (res != SCSI_SCAN_LUN_PRESENT)
1261 sdev = ERR_PTR(-ENODEV);
1262 }
1263 mutex_unlock(&shost->scan_mutex); 1258 mutex_unlock(&shost->scan_mutex);
1264 scsi_target_reap(starget); 1259 scsi_target_reap(starget);
1265 put_device(&starget->dev); 1260 put_device(&starget->dev);