[PATCH V2] scsi: aacraid: Fix some error code

From: Christophe JAILLET
Date: Mon Oct 23 2017 - 22:31:42 EST


If 'scsi_host_alloc', 'kzalloc' or '(*aac_drivers[index].init)' fail, the
function will return 0, because 'error' is known to be 0 at this point.

Return -ENOMEM in the 2 first cases and -ENODEV in the third one.

This patch also removes a useless 'error = -ENODEV'.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
V2: rebase against latest -next (20171019)
---
drivers/scsi/aacraid/linit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index c9252b138c1f..7e7d9bfd2b9e 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1628,7 +1628,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
error = pci_enable_device(pdev);
if (error)
goto out;
- error = -ENODEV;

if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
@@ -1660,6 +1659,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_master(pdev);

shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
+ error = -ENOMEM;
if (!shost)
goto out_disable_pdev;

@@ -1681,6 +1681,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
INIT_LIST_HEAD(&aac->entry);

aac->fibs = kzalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL);
+ error = -ENOMEM;
if (!aac->fibs)
goto out_free_host;
spin_lock_init(&aac->fib_lock);
@@ -1690,6 +1691,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
* Map in the registers from the adapter.
*/
aac->base_size = AAC_MIN_FOOTPRINT_SIZE;
+ error = -ENODEV;
if ((*aac_drivers[index].init)(aac))
goto out_unmap;

--
2.14.1