| From foo@baz Mon Sep 17 12:33:31 CEST 2018 |
| From: Anton Vasilyev <vasilyev@ispras.ru> |
| Date: Fri, 27 Jul 2018 16:51:57 +0300 |
| Subject: scsi: 3ware: fix return 0 on the error path of probe |
| |
| From: Anton Vasilyev <vasilyev@ispras.ru> |
| |
| [ Upstream commit 4dc98c1995482262e70e83ef029135247fafe0f2 ] |
| |
| 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> |
| Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/scsi/3w-9xxx.c | 6 +++++- |
| drivers/scsi/3w-sas.c | 3 +++ |
| drivers/scsi/3w-xxxx.c | 2 ++ |
| 3 files changed, 10 insertions(+), 1 deletion(-) |
| |
| --- a/drivers/scsi/3w-9xxx.c |
| +++ b/drivers/scsi/3w-9xxx.c |
| @@ -2042,6 +2042,7 @@ static int twa_probe(struct pci_dev *pde |
| |
| if (twa_initialize_device_extension(tw_dev)) { |
| TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension"); |
| + retval = -ENOMEM; |
| goto out_free_device_extension; |
| } |
| |
| @@ -2064,6 +2065,7 @@ static int twa_probe(struct pci_dev *pde |
| tw_dev->base_addr = ioremap(mem_addr, mem_len); |
| if (!tw_dev->base_addr) { |
| TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); |
| + retval = -ENOMEM; |
| goto out_release_mem_region; |
| } |
| |
| @@ -2071,8 +2073,10 @@ static int twa_probe(struct pci_dev *pde |
| TW_DISABLE_INTERRUPTS(tw_dev); |
| |
| /* Initialize the card */ |
| - if (twa_reset_sequence(tw_dev, 0)) |
| + if (twa_reset_sequence(tw_dev, 0)) { |
| + retval = -ENOMEM; |
| goto out_iounmap; |
| + } |
| |
| /* Set host specific parameters */ |
| if ((pdev->device == PCI_DEVICE_ID_3WARE_9650SE) || |
| --- a/drivers/scsi/3w-sas.c |
| +++ b/drivers/scsi/3w-sas.c |
| @@ -1597,6 +1597,7 @@ static int twl_probe(struct pci_dev *pde |
| |
| if (twl_initialize_device_extension(tw_dev)) { |
| TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension"); |
| + retval = -ENOMEM; |
| goto out_free_device_extension; |
| } |
| |
| @@ -1611,6 +1612,7 @@ static int twl_probe(struct pci_dev *pde |
| tw_dev->base_addr = pci_iomap(pdev, 1, 0); |
| if (!tw_dev->base_addr) { |
| TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap"); |
| + retval = -ENOMEM; |
| goto out_release_mem_region; |
| } |
| |
| @@ -1620,6 +1622,7 @@ static int twl_probe(struct pci_dev *pde |
| /* Initialize the card */ |
| if (twl_reset_sequence(tw_dev, 0)) { |
| TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe"); |
| + retval = -ENOMEM; |
| goto out_iounmap; |
| } |
| |
| --- a/drivers/scsi/3w-xxxx.c |
| +++ b/drivers/scsi/3w-xxxx.c |
| @@ -2280,6 +2280,7 @@ static int tw_probe(struct pci_dev *pdev |
| |
| if (tw_initialize_device_extension(tw_dev)) { |
| printk(KERN_WARNING "3w-xxxx: Failed to initialize device extension."); |
| + retval = -ENOMEM; |
| goto out_free_device_extension; |
| } |
| |
| @@ -2294,6 +2295,7 @@ static int tw_probe(struct pci_dev *pdev |
| tw_dev->base_addr = pci_resource_start(pdev, 0); |
| if (!tw_dev->base_addr) { |
| printk(KERN_WARNING "3w-xxxx: Failed to get io address."); |
| + retval = -ENOMEM; |
| goto out_release_mem_region; |
| } |
| |