scsi: aacraid: Fix error handling paths in aac_probe_one()

If 'scsi_host_alloc()' or 'kcalloc()' fail, 'error' is known to be 0. Set
it explicitly to -ENOMEM before branching to the error handling path.

While at it, remove 2 useless assignments to 'error'. These values are
overwridden a few lines later.

Link: https://lore.kernel.org/r/20200412094039.8822-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Christophe JAILLET 2020-04-12 11:40:39 +02:00 committed by Martin K. Petersen
parent f371d53453
commit f7854c3822
1 changed files with 8 additions and 4 deletions

View File

@ -1632,7 +1632,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
struct Scsi_Host *shost; struct Scsi_Host *shost;
struct aac_dev *aac; struct aac_dev *aac;
struct list_head *insert = &aac_devices; struct list_head *insert = &aac_devices;
int error = -ENODEV; int error;
int unique_id = 0; int unique_id = 0;
u64 dmamask; u64 dmamask;
int mask_bits = 0; int mask_bits = 0;
@ -1657,7 +1657,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
error = pci_enable_device(pdev); error = pci_enable_device(pdev);
if (error) if (error)
goto out; goto out;
error = -ENODEV;
if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) { if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
@ -1689,8 +1688,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_master(pdev); pci_set_master(pdev);
shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev)); shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
if (!shost) if (!shost) {
error = -ENOMEM;
goto out_disable_pdev; goto out_disable_pdev;
}
shost->irq = pdev->irq; shost->irq = pdev->irq;
shost->unique_id = unique_id; shost->unique_id = unique_id;
@ -1714,8 +1715,11 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB, aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB,
sizeof(struct fib), sizeof(struct fib),
GFP_KERNEL); GFP_KERNEL);
if (!aac->fibs) if (!aac->fibs) {
error = -ENOMEM;
goto out_free_host; goto out_free_host;
}
spin_lock_init(&aac->fib_lock); spin_lock_init(&aac->fib_lock);
mutex_init(&aac->ioctl_mutex); mutex_init(&aac->ioctl_mutex);