Skip to content

Commit 18178e0

Browse files
Peng Wumiquelraynal
authored andcommitted
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
1 parent f2906aa commit 18178e0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/mtd/nand/raw/cafe_nand.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
679679
pci_set_master(pdev);
680680

681681
cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
682-
if (!cafe)
683-
return -ENOMEM;
682+
if (!cafe) {
683+
err = -ENOMEM;
684+
goto out_disable_device;
685+
}
684686

685687
mtd = nand_to_mtd(&cafe->nand);
686688
mtd->dev.parent = &pdev->dev;
@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
801803
pci_iounmap(pdev, cafe->mmio);
802804
out_free_mtd:
803805
kfree(cafe);
806+
out_disable_device:
807+
pci_disable_device(pdev);
804808
out:
805809
return err;
806810
}
@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
822826
pci_iounmap(pdev, cafe->mmio);
823827
dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
824828
kfree(cafe);
829+
pci_disable_device(pdev);
825830
}
826831

827832
static const struct pci_device_id cafe_nand_tbl[] = {

0 commit comments

Comments
 (0)