diff options
author | Peng Wu <wupeng58@huawei.com> | 2022-05-20 08:44:25 +0000 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2022-06-06 14:58:24 +0200 |
commit | 18178e03b124b0c6be17abbbca914157642f5d7a (patch) | |
tree | 77be9107c2cfb40e85a1ef705f1c47bb326fba3e /drivers/mtd/nand | |
parent | f2906aa863381afb0015a9eb7fefad885d4e5a56 (diff) | |
download | linux-stable-18178e03b124b0c6be17abbbca914157642f5d7a.tar.gz linux-stable-18178e03b124b0c6be17abbbca914157642f5d7a.tar.bz2 linux-stable-18178e03b124b0c6be17abbbca914157642f5d7a.zip |
mtd: rawnand: cafe: fix drivers probe/remove methods
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: Peng Wu <wupeng58@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220520084425.116686-1-wupeng58@huawei.com
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/raw/cafe_nand.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c index 9dbf031716a6..af119e376352 100644 --- a/drivers/mtd/nand/raw/cafe_nand.c +++ b/drivers/mtd/nand/raw/cafe_nand.c @@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev, pci_set_master(pdev); cafe = kzalloc(sizeof(*cafe), GFP_KERNEL); - if (!cafe) - return -ENOMEM; + if (!cafe) { + err = -ENOMEM; + goto out_disable_device; + } mtd = nand_to_mtd(&cafe->nand); mtd->dev.parent = &pdev->dev; @@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev, pci_iounmap(pdev, cafe->mmio); out_free_mtd: kfree(cafe); + out_disable_device: + pci_disable_device(pdev); out: return err; } @@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) pci_iounmap(pdev, cafe->mmio); dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); kfree(cafe); + pci_disable_device(pdev); } static const struct pci_device_id cafe_nand_tbl[] = { |