Skip to content

Commit 0792ec8

Browse files
eunovmmiquelraynal
authored andcommitted
mtd: rawnand: intel: Fix error handling in probe
ebu_nand_probe() did not invoke ebu_dma_cleanup() and clk_disable_unprepare() on some error handling paths. The patch fixes that. Found by Linux Driver Verification project (linuxtesting.org). Fixes: 0b1039f ("mtd: rawnand: Add NAND controller support on Intel LGM SoC") Signed-off-by: Evgeny Novikov <[email protected]> Co-developed-by: Kirill Shilimanov <[email protected]> Signed-off-by: Kirill Shilimanov <[email protected]> Co-developed-by: Anton Vasilyev <[email protected]> Signed-off-by: Anton Vasilyev <[email protected]> Cc: [email protected] Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 6f80269 commit 0792ec8

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

drivers/mtd/nand/raw/intel-nand-controller.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,19 +631,26 @@ static int ebu_nand_probe(struct platform_device *pdev)
631631
ebu_host->clk_rate = clk_get_rate(ebu_host->clk);
632632

633633
ebu_host->dma_tx = dma_request_chan(dev, "tx");
634-
if (IS_ERR(ebu_host->dma_tx))
635-
return dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx),
636-
"failed to request DMA tx chan!.\n");
634+
if (IS_ERR(ebu_host->dma_tx)) {
635+
ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx),
636+
"failed to request DMA tx chan!.\n");
637+
goto err_disable_unprepare_clk;
638+
}
637639

638640
ebu_host->dma_rx = dma_request_chan(dev, "rx");
639-
if (IS_ERR(ebu_host->dma_rx))
640-
return dev_err_probe(dev, PTR_ERR(ebu_host->dma_rx),
641-
"failed to request DMA rx chan!.\n");
641+
if (IS_ERR(ebu_host->dma_rx)) {
642+
ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_rx),
643+
"failed to request DMA rx chan!.\n");
644+
ebu_host->dma_rx = NULL;
645+
goto err_cleanup_dma;
646+
}
642647

643648
resname = devm_kasprintf(dev, GFP_KERNEL, "addr_sel%d", cs);
644649
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resname);
645-
if (!res)
646-
return -EINVAL;
650+
if (!res) {
651+
ret = -EINVAL;
652+
goto err_cleanup_dma;
653+
}
647654
ebu_host->cs[cs].addr_sel = res->start;
648655
writel(ebu_host->cs[cs].addr_sel | EBU_ADDR_MASK(5) | EBU_ADDR_SEL_REGEN,
649656
ebu_host->ebu + EBU_ADDR_SEL(cs));
@@ -653,7 +660,8 @@ static int ebu_nand_probe(struct platform_device *pdev)
653660
mtd = nand_to_mtd(&ebu_host->chip);
654661
if (!mtd->name) {
655662
dev_err(ebu_host->dev, "NAND label property is mandatory\n");
656-
return -EINVAL;
663+
ret = -EINVAL;
664+
goto err_cleanup_dma;
657665
}
658666

659667
mtd->dev.parent = dev;
@@ -681,6 +689,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
681689
nand_cleanup(&ebu_host->chip);
682690
err_cleanup_dma:
683691
ebu_dma_cleanup(ebu_host);
692+
err_disable_unprepare_clk:
684693
clk_disable_unprepare(ebu_host->clk);
685694

686695
return ret;

0 commit comments

Comments
 (0)