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> --- 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 0f277df73af0..43691d6febc2 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1473,7 +1473,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)); @@ -1505,6 +1504,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; @@ -1526,6 +1526,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); @@ -1535,6 +1536,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.11.0