summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Vasilyev <vasilyev@ispras.ru>2018-07-27 09:51:57 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-07-30 23:17:53 -0400
commit4dc98c1995482262e70e83ef029135247fafe0f2 (patch)
tree8d71d32c2cf48ad64eefd80085dda9e667baad07
parentdcaa0c12661d862bc533239da22ddf2ed90595e7 (diff)
scsi: 3ware: fix return 0 on the error path of probe
tw_probe() returns 0 in case of fail of tw_initialize_device_extension(), pci_resource_start() or tw_reset_sequence() and releases resources. twl_probe() returns 0 in case of fail of twl_initialize_device_extension(), pci_iomap() and twl_reset_sequence(). twa_probe() returns 0 in case of fail of tw_initialize_device_extension(), ioremap() and twa_reset_sequence(). The patch adds retval initialization for these cases. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru> Acked-by: Adam Radford <aradford@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/3w-9xxx.c6
-rw-r--r--drivers/scsi/3w-sas.c3
-rw-r--r--drivers/scsi/3w-xxxx.c2
3 files changed, 10 insertions, 1 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 99ba4a770406..27521fc3ef5a 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -2038,6 +2038,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
2038 2038
2039 if (twa_initialize_device_extension(tw_dev)) { 2039 if (twa_initialize_device_extension(tw_dev)) {
2040 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension"); 2040 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension");
2041 retval = -ENOMEM;
2041 goto out_free_device_extension; 2042 goto out_free_device_extension;
2042 } 2043 }
2043 2044
@@ -2060,6 +2061,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
2060 tw_dev->base_addr = ioremap(mem_addr, mem_len); 2061 tw_dev->base_addr = ioremap(mem_addr, mem_len);
2061 if (!tw_dev->base_addr) { 2062 if (!tw_dev->base_addr) {
2062 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); 2063 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
2064 retval = -ENOMEM;
2063 goto out_release_mem_region; 2065 goto out_release_mem_region;
2064 } 2066 }
2065 2067
@@ -2067,8 +2069,10 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
2067 TW_DISABLE_INTERRUPTS(tw_dev); 2069 TW_DISABLE_INTERRUPTS(tw_dev);
2068 2070
2069 /* Initialize the card */ 2071 /* Initialize the card */
2070 if (twa_reset_sequence(tw_dev, 0)) 2072 if (twa_reset_sequence(tw_dev, 0)) {
2073 retval = -ENOMEM;
2071 goto out_iounmap; 2074 goto out_iounmap;
2075 }
2072 2076
2073 /* Set host specific parameters */ 2077 /* Set host specific parameters */
2074 if ((pdev->device == PCI_DEVICE_ID_3WARE_9650SE) || 2078 if ((pdev->device == PCI_DEVICE_ID_3WARE_9650SE) ||
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index cf9f2a09b47d..40c1e6e64f58 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1594,6 +1594,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
1594 1594
1595 if (twl_initialize_device_extension(tw_dev)) { 1595 if (twl_initialize_device_extension(tw_dev)) {
1596 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension"); 1596 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension");
1597 retval = -ENOMEM;
1597 goto out_free_device_extension; 1598 goto out_free_device_extension;
1598 } 1599 }
1599 1600
@@ -1608,6 +1609,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
1608 tw_dev->base_addr = pci_iomap(pdev, 1, 0); 1609 tw_dev->base_addr = pci_iomap(pdev, 1, 0);
1609 if (!tw_dev->base_addr) { 1610 if (!tw_dev->base_addr) {
1610 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap"); 1611 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap");
1612 retval = -ENOMEM;
1611 goto out_release_mem_region; 1613 goto out_release_mem_region;
1612 } 1614 }
1613 1615
@@ -1617,6 +1619,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
1617 /* Initialize the card */ 1619 /* Initialize the card */
1618 if (twl_reset_sequence(tw_dev, 0)) { 1620 if (twl_reset_sequence(tw_dev, 0)) {
1619 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe"); 1621 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe");
1622 retval = -ENOMEM;
1620 goto out_iounmap; 1623 goto out_iounmap;
1621 } 1624 }
1622 1625
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index a40d353bd8b3..471366945bd4 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -2280,6 +2280,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
2280 2280
2281 if (tw_initialize_device_extension(tw_dev)) { 2281 if (tw_initialize_device_extension(tw_dev)) {
2282 printk(KERN_WARNING "3w-xxxx: Failed to initialize device extension."); 2282 printk(KERN_WARNING "3w-xxxx: Failed to initialize device extension.");
2283 retval = -ENOMEM;
2283 goto out_free_device_extension; 2284 goto out_free_device_extension;
2284 } 2285 }
2285 2286
@@ -2294,6 +2295,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
2294 tw_dev->base_addr = pci_resource_start(pdev, 0); 2295 tw_dev->base_addr = pci_resource_start(pdev, 0);
2295 if (!tw_dev->base_addr) { 2296 if (!tw_dev->base_addr) {
2296 printk(KERN_WARNING "3w-xxxx: Failed to get io address."); 2297 printk(KERN_WARNING "3w-xxxx: Failed to get io address.");
2298 retval = -ENOMEM;
2297 goto out_release_mem_region; 2299 goto out_release_mem_region;
2298 } 2300 }
2299 2301