aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMark Haverkamp <markh@osdl.org>2006-08-03 11:03:07 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-08-19 16:33:45 -0400
commit90ee346651524eb275405d410f5d3bb6765a2d93 (patch)
treeff78b321da9aafb44dfbe593f0c7dbe7f88f053e /drivers/scsi
parent8c23cd7457151fc8ace79ec700a8aeaa9fc5b3d9 (diff)
[SCSI] aacraid: Check for unlikely errors
Received from Mark Salyzyn The enclosed patch cleans up some code fragments, adds some paranoia (unproven causes of potential driver failures). Signed-off-by: Mark Haverkamp <markh@osdl.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/aacraid/aachba.c15
-rw-r--r--drivers/scsi/aacraid/comminit.c2
-rw-r--r--drivers/scsi/aacraid/linit.c4
3 files changed, 18 insertions, 3 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 83b5c7d085f2..699351c15cc9 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -489,6 +489,8 @@ int aac_probe_container(struct aac_dev *dev, int cid)
489 unsigned instance; 489 unsigned instance;
490 490
491 fsa_dev_ptr = dev->fsa_dev; 491 fsa_dev_ptr = dev->fsa_dev;
492 if (!fsa_dev_ptr)
493 return -ENOMEM;
492 instance = dev->scsi_host_ptr->unique_id; 494 instance = dev->scsi_host_ptr->unique_id;
493 495
494 if (!(fibptr = aac_fib_alloc(dev))) 496 if (!(fibptr = aac_fib_alloc(dev)))
@@ -1392,6 +1394,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid)
1392 struct scsi_cmnd *cmd; 1394 struct scsi_cmnd *cmd;
1393 struct scsi_device *sdev = scsicmd->device; 1395 struct scsi_device *sdev = scsicmd->device;
1394 int active = 0; 1396 int active = 0;
1397 struct aac_dev *aac;
1395 unsigned long flags; 1398 unsigned long flags;
1396 1399
1397 /* 1400 /*
@@ -1413,11 +1416,11 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid)
1413 if (active) 1416 if (active)
1414 return SCSI_MLQUEUE_DEVICE_BUSY; 1417 return SCSI_MLQUEUE_DEVICE_BUSY;
1415 1418
1419 aac = (struct aac_dev *)scsicmd->device->host->hostdata;
1416 /* 1420 /*
1417 * Allocate and initialize a Fib 1421 * Allocate and initialize a Fib
1418 */ 1422 */
1419 if (!(cmd_fibcontext = 1423 if (!(cmd_fibcontext = aac_fib_alloc(aac)))
1420 aac_fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata)))
1421 return SCSI_MLQUEUE_HOST_BUSY; 1424 return SCSI_MLQUEUE_HOST_BUSY;
1422 1425
1423 aac_fib_init(cmd_fibcontext); 1426 aac_fib_init(cmd_fibcontext);
@@ -1470,6 +1473,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1470 struct aac_dev *dev = (struct aac_dev *)host->hostdata; 1473 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
1471 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev; 1474 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
1472 1475
1476 if (fsa_dev_ptr == NULL)
1477 return -1;
1473 /* 1478 /*
1474 * If the bus, id or lun is out of range, return fail 1479 * If the bus, id or lun is out of range, return fail
1475 * Test does not apply to ID 16, the pseudo id for the controller 1480 * Test does not apply to ID 16, the pseudo id for the controller
@@ -1782,6 +1787,8 @@ static int query_disk(struct aac_dev *dev, void __user *arg)
1782 struct fsa_dev_info *fsa_dev_ptr; 1787 struct fsa_dev_info *fsa_dev_ptr;
1783 1788
1784 fsa_dev_ptr = dev->fsa_dev; 1789 fsa_dev_ptr = dev->fsa_dev;
1790 if (!fsa_dev_ptr)
1791 return -ENODEV;
1785 if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk))) 1792 if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
1786 return -EFAULT; 1793 return -EFAULT;
1787 if (qd.cnum == -1) 1794 if (qd.cnum == -1)
@@ -1843,6 +1850,10 @@ static int delete_disk(struct aac_dev *dev, void __user *arg)
1843 struct fsa_dev_info *fsa_dev_ptr; 1850 struct fsa_dev_info *fsa_dev_ptr;
1844 1851
1845 fsa_dev_ptr = dev->fsa_dev; 1852 fsa_dev_ptr = dev->fsa_dev;
1853 if (!fsa_dev_ptr)
1854 return -ENODEV;
1855 if (!fsa_dev_ptr)
1856 return -ENODEV;
1846 1857
1847 if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk))) 1858 if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
1848 return -EFAULT; 1859 return -EFAULT;
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 1cd3584ba7ff..87a955096761 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -180,7 +180,7 @@ int aac_send_shutdown(struct aac_dev * dev)
180 -2 /* Timeout silently */, 1, 180 -2 /* Timeout silently */, 1,
181 NULL, NULL); 181 NULL, NULL);
182 182
183 if (status == 0) 183 if (status >= 0)
184 aac_fib_complete(fibctx); 184 aac_fib_complete(fibctx);
185 aac_fib_free(fibctx); 185 aac_fib_free(fibctx);
186 return status; 186 return status;
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index e42a479ce64a..9d8b550a91cb 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1013,6 +1013,10 @@ static void __devexit aac_remove_one(struct pci_dev *pdev)
1013 list_del(&aac->entry); 1013 list_del(&aac->entry);
1014 scsi_host_put(shost); 1014 scsi_host_put(shost);
1015 pci_disable_device(pdev); 1015 pci_disable_device(pdev);
1016 if (list_empty(&aac_devices)) {
1017 unregister_chrdev(aac_cfg_major, "aac");
1018 aac_cfg_major = -1;
1019 }
1016} 1020}
1017 1021
1018static struct pci_driver aac_pci_driver = { 1022static struct pci_driver aac_pci_driver = {