]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mtd: rawnand: ingenic: handle ECC clock enable failures
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Mon, 15 Jun 2026 06:33:32 +0000 (14:33 +0800)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 29 Jun 2026 14:39:14 +0000 (16:39 +0200)
ingenic_ecc_get() obtains a provider device reference and then enables
the ECC clock before returning the ECC handle.

The clk_prepare_enable() return value is currently ignored.  If enabling
the clock fails, the function still returns the ECC handle and keeps the
provider device reference even though the acquire operation did not
complete.

Return the clock enable error and drop the provider device reference on
that failure path.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/ingenic/ingenic_ecc.c

index 525c34c281b65df0aba78168b3eb13260b14b4fb..beb033705cf3e7ad0faefa1f79d4fd19ed843fd4 100644 (file)
@@ -67,6 +67,7 @@ static struct ingenic_ecc *ingenic_ecc_get(struct device_node *np)
 {
        struct platform_device *pdev;
        struct ingenic_ecc *ecc;
+       int ret;
 
        pdev = of_find_device_by_node(np);
        if (!pdev)
@@ -78,7 +79,11 @@ static struct ingenic_ecc *ingenic_ecc_get(struct device_node *np)
        }
 
        ecc = platform_get_drvdata(pdev);
-       clk_prepare_enable(ecc->clk);
+       ret = clk_prepare_enable(ecc->clk);
+       if (ret) {
+               put_device(&pdev->dev);
+               return ERR_PTR(ret);
+       }
 
        return ecc;
 }