提交 9fa804b5 编写于 作者: P Peng Wu 提交者: Zheng Zengkai

mtd: rawnand: cafe: fix drivers probe/remove methods

mainline inclusion
from mainline-v6.0-rc1
commit 18178e03
category: bugfix
bugzilla: 187764, https://gitee.com/openeuler/kernel/issues/I5XJD7
CVE: N/A

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0&id=18178e03b124b0c6be17abbbca914157642f5d7a

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

Driver should call pci_disable_device() if it returns from
cafe_nand_probe() with error.

Meanwhile, the driver calls pci_enable_device() in
cafe_nand_probe(), but never calls pci_disable_device()
during removal.
Signed-off-by: NPeng Wu <wupeng58@huawei.com>
Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220520084425.116686-1-wupeng58@huawei.comSigned-off-by: NGONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
Reviewed-by: Nyiyang <yiyang13@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c86c1653
...@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
pci_set_master(pdev); pci_set_master(pdev);
cafe = kzalloc(sizeof(*cafe), GFP_KERNEL); cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
if (!cafe) if (!cafe) {
return -ENOMEM; err = -ENOMEM;
goto out_disable_device;
}
mtd = nand_to_mtd(&cafe->nand); mtd = nand_to_mtd(&cafe->nand);
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
...@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
pci_iounmap(pdev, cafe->mmio); pci_iounmap(pdev, cafe->mmio);
out_free_mtd: out_free_mtd:
kfree(cafe); kfree(cafe);
out_disable_device:
pci_disable_device(pdev);
out: out:
return err; return err;
} }
...@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) ...@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
pci_iounmap(pdev, cafe->mmio); pci_iounmap(pdev, cafe->mmio);
dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
kfree(cafe); kfree(cafe);
pci_disable_device(pdev);
} }
static const struct pci_device_id cafe_nand_tbl[] = { static const struct pci_device_id cafe_nand_tbl[] = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册