Skip to content

Commit 1f3b494

Browse files
Yang Yingliangmiquelraynal
authored andcommitted
mtd: rawnand: intel: Add missing of_node_put() in ebu_nand_probe()
The 'chip_np' returned by of_get_next_child() with refcount decremented, of_node_put() need be called in error path to decrease the refcount. Fixes: bfc618f ("mtd: rawnand: intel: Read the chip-select line from the correct OF node") Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Martin Blumenstingl <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 12b5896 commit 1f3b494

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,30 +608,35 @@ static int ebu_nand_probe(struct platform_device *pdev)
608608
ret = of_property_read_u32(chip_np, "reg", &cs);
609609
if (ret) {
610610
dev_err(dev, "failed to get chip select: %d\n", ret);
611-
return ret;
611+
goto err_of_node_put;
612612
}
613613
if (cs >= MAX_CS) {
614614
dev_err(dev, "got invalid chip select: %d\n", cs);
615-
return -EINVAL;
615+
ret = -EINVAL;
616+
goto err_of_node_put;
616617
}
617618

618619
ebu_host->cs_num = cs;
619620

620621
resname = devm_kasprintf(dev, GFP_KERNEL, "nand_cs%d", cs);
621622
ebu_host->cs[cs].chipaddr = devm_platform_ioremap_resource_byname(pdev,
622623
resname);
623-
if (IS_ERR(ebu_host->cs[cs].chipaddr))
624-
return PTR_ERR(ebu_host->cs[cs].chipaddr);
624+
if (IS_ERR(ebu_host->cs[cs].chipaddr)) {
625+
ret = PTR_ERR(ebu_host->cs[cs].chipaddr);
626+
goto err_of_node_put;
627+
}
625628

626629
ebu_host->clk = devm_clk_get(dev, NULL);
627-
if (IS_ERR(ebu_host->clk))
628-
return dev_err_probe(dev, PTR_ERR(ebu_host->clk),
629-
"failed to get clock\n");
630+
if (IS_ERR(ebu_host->clk)) {
631+
ret = dev_err_probe(dev, PTR_ERR(ebu_host->clk),
632+
"failed to get clock\n");
633+
goto err_of_node_put;
634+
}
630635

631636
ret = clk_prepare_enable(ebu_host->clk);
632637
if (ret) {
633638
dev_err(dev, "failed to enable clock: %d\n", ret);
634-
return ret;
639+
goto err_of_node_put;
635640
}
636641

637642
ebu_host->dma_tx = dma_request_chan(dev, "tx");
@@ -695,6 +700,8 @@ static int ebu_nand_probe(struct platform_device *pdev)
695700
ebu_dma_cleanup(ebu_host);
696701
err_disable_unprepare_clk:
697702
clk_disable_unprepare(ebu_host->clk);
703+
err_of_node_put:
704+
of_node_put(chip_np);
698705

699706
return ret;
700707
}

0 commit comments

Comments
 (0)