diff options
author | Matthew Wilcox <matthew@wil.cx> | 2006-02-05 16:01:33 +0100 |
---|---|---|
committer | <jejb@mulgrave.il.steeleye.com> | 2006-02-28 05:55:07 +0100 |
commit | a97a83a06b44d4d1cb01191423caf9813a150b95 (patch) | |
tree | f74949bd8b8374036d19947b43f3e6d239eb5710 /drivers | |
parent | [SCSI] cciss: kfree(NULL) is legal (diff) | |
download | linux-a97a83a06b44d4d1cb01191423caf9813a150b95.tar.xz linux-a97a83a06b44d4d1cb01191423caf9813a150b95.zip |
[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 '')
-rw-r--r-- | drivers/scsi/scsi_scan.c | 11 |
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, struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, uint id, uint lun, void *hostdata) { - struct scsi_device *sdev; + struct scsi_device *sdev = ERR_PTR(-ENODEV); struct device *parent = &shost->shost_gendev; - int res; struct scsi_target *starget; starget = scsi_alloc_target(parent, channel, id); @@ -1254,12 +1253,8 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, get_device(&starget->dev); mutex_lock(&shost->scan_mutex); - if (scsi_host_scan_allowed(shost)) { - res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, - hostdata); - if (res != SCSI_SCAN_LUN_PRESENT) - sdev = ERR_PTR(-ENODEV); - } + if (scsi_host_scan_allowed(shost)) + scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); mutex_unlock(&shost->scan_mutex); scsi_target_reap(starget); put_device(&starget->dev); |