提交 3c80ffbb 编写于 作者: H Hannes Reinecke 提交者: Zheng Zengkai

scsi: myrb: Fix up null pointer access on myrb_cleanup()

stable inclusion
from stable-v5.10.122
commit ebfe2797253f64f728855d377fdc7d136fdbcfb5
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5W6OE

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ebfe2797253f64f728855d377fdc7d136fdbcfb5

--------------------------------

[ Upstream commit f9f0a461 ]

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.deReported-by: NZheyu Ma <zheyuma97@gmail.com>
Tested-by: NZheyu Ma <zheyuma97@gmail.com>
Signed-off-by: NHannes Reinecke <hare@suse.de>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 5321a9b0
......@@ -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)
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册