Skip to content

Commit f9f0a46

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: myrb: Fix up null pointer access on myrb_cleanup()
When myrb_probe() fails the callback might not be set, so we need to validate the 'disable_intr' callback in myrb_cleanup() to not cause a null pointer exception. And while at it do not call myrb_cleanup() if we cannot enable the PCI device at all. Link: https://lore.kernel.org/r/[email protected] Reported-by: Zheyu Ma <[email protected]> Tested-by: Zheyu Ma <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7ad36c8 commit f9f0a46

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/scsi/myrb.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,8 @@ static void myrb_cleanup(struct myrb_hba *cb)
12391239
myrb_unmap(cb);
12401240

12411241
if (cb->mmio_base) {
1242-
cb->disable_intr(cb->io_base);
1242+
if (cb->disable_intr)
1243+
cb->disable_intr(cb->io_base);
12431244
iounmap(cb->mmio_base);
12441245
}
12451246
if (cb->irq)
@@ -3413,9 +3414,13 @@ static struct myrb_hba *myrb_detect(struct pci_dev *pdev,
34133414
mutex_init(&cb->dcmd_mutex);
34143415
mutex_init(&cb->dma_mutex);
34153416
cb->pdev = pdev;
3417+
cb->host = shost;
34163418

3417-
if (pci_enable_device(pdev))
3418-
goto failure;
3419+
if (pci_enable_device(pdev)) {
3420+
dev_err(&pdev->dev, "Failed to enable PCI device\n");
3421+
scsi_host_put(shost);
3422+
return NULL;
3423+
}
34193424

34203425
if (privdata->hw_init == DAC960_PD_hw_init ||
34213426
privdata->hw_init == DAC960_P_hw_init) {

0 commit comments

Comments
 (0)