]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mtd: rawnand: intel: Add missing of_node_put() in ebu_nand_probe()
authorYang Yingliang <yangyingliang@huawei.com>
Sat, 24 Sep 2022 13:10:10 +0000 (21:10 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 28 Nov 2022 14:18:12 +0000 (15:18 +0100)
BugLink: https://bugs.launchpad.net/bugs/1997981
[ Upstream commit 1f3b494d1fc18ebb37aaa47107e9b84bf5b54ff7 ]

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: bfc618fcc3f1 ("mtd: rawnand: intel: Read the chip-select line from the correct OF node")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220924131010.957117-1-yangyingliang@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/mtd/nand/raw/intel-nand-controller.c

index 056835fd4562285aef1880b9fea22d25f92dcdf7..53071e791e179f6f988a57a16f357975a1a32f29 100644 (file)
@@ -614,11 +614,12 @@ static int ebu_nand_probe(struct platform_device *pdev)
        ret = of_property_read_u32(chip_np, "reg", &cs);
        if (ret) {
                dev_err(dev, "failed to get chip select: %d\n", ret);
-               return ret;
+               goto err_of_node_put;
        }
        if (cs >= MAX_CS) {
                dev_err(dev, "got invalid chip select: %d\n", cs);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto err_of_node_put;
        }
 
        ebu_host->cs_num = cs;
@@ -627,18 +628,20 @@ static int ebu_nand_probe(struct platform_device *pdev)
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resname);
        ebu_host->cs[cs].chipaddr = devm_ioremap_resource(dev, res);
        if (IS_ERR(ebu_host->cs[cs].chipaddr))
-               return PTR_ERR(ebu_host->cs[cs].chipaddr);
+               goto err_of_node_put;
        ebu_host->cs[cs].nand_pa = res->start;
 
        ebu_host->clk = devm_clk_get(dev, NULL);
-       if (IS_ERR(ebu_host->clk))
-               return dev_err_probe(dev, PTR_ERR(ebu_host->clk),
-                                    "failed to get clock\n");
+       if (IS_ERR(ebu_host->clk)) {
+               ret = dev_err_probe(dev, PTR_ERR(ebu_host->clk),
+                                   "failed to get clock\n");
+               goto err_of_node_put;
+       }
 
        ret = clk_prepare_enable(ebu_host->clk);
        if (ret) {
                dev_err(dev, "failed to enable clock: %d\n", ret);
-               return ret;
+               goto err_of_node_put;
        }
        ebu_host->clk_rate = clk_get_rate(ebu_host->clk);
 
@@ -703,6 +706,8 @@ err_cleanup_dma:
        ebu_dma_cleanup(ebu_host);
 err_disable_unprepare_clk:
        clk_disable_unprepare(ebu_host->clk);
+err_of_node_put:
+       of_node_put(chip_np);
 
        return ret;
 }