Skip to content

Commit

Permalink
scsi: myrb: Fix up null pointer access on myrb_cleanup()
Browse files Browse the repository at this point in the history
[ Upstream commit f9f0a46 ]

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/20220523120244.99515-1-hare@suse.de
Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Tested-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
hreinecke authored and gregkh committed Jun 14, 2022
1 parent 7eb32f2 commit ebfe279
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/scsi/myrb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,8 @@ static void myrb_cleanup(struct myrb_hba *cb)
myrb_unmap(cb);

if (cb->mmio_base) {
cb->disable_intr(cb->io_base);
if (cb->disable_intr)
cb->disable_intr(cb->io_base);
iounmap(cb->mmio_base);
}
if (cb->irq)
Expand Down Expand Up @@ -3515,9 +3516,13 @@ static struct myrb_hba *myrb_detect(struct pci_dev *pdev,
mutex_init(&cb->dcmd_mutex);
mutex_init(&cb->dma_mutex);
cb->pdev = pdev;
cb->host = shost;

if (pci_enable_device(pdev))
goto failure;
if (pci_enable_device(pdev)) {
dev_err(&pdev->dev, "Failed to enable PCI device\n");
scsi_host_put(shost);
return NULL;
}

if (privdata->hw_init == DAC960_PD_hw_init ||
privdata->hw_init == DAC960_P_hw_init) {
Expand Down

0 comments on commit ebfe279

Please sign in to comment.