Skip to contentSkip to conversation

mtd: rawnand: ingenic: Fix missing put_device in ingenic_ecc_get

PATCH Applied Miaoqian Lin 3 participants 4 messages Dec 30, 2021 – Jan 23, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: ingenic: Fix missing put_device in ingenic_ecc_get

If of_find_device_by_node() succeeds, ingenic_ecc_get() doesn't have a corresponding put_device(). Thus add put_device() to fix the exception handling.

Fixes 15de8c6 ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")
---
 drivers/mtd/nand/raw/ingenic/ingenic_ecc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/ingenic/ingenic_ecc.c +6 -1
index efe0ffe4f1ab..9054559e52dd 100644
@@ -68,9 +68,14 @@ static struct ingenic_ecc *ingenic_ecc_get(struct device_node *np)
 	struct ingenic_ecc *ecc;
 
 	pdev = of_find_device_by_node(np);
-	if (!pdev || !platform_get_drvdata(pdev))
+	if (!pdev)
 		return ERR_PTR(-EPROBE_DEFER);
 
+	if (!platform_get_drvdata(pdev)) {
+		put_device(&pdev->dev);
+		return ERR_PTR(-EPROBE_DEFER);
+	}
+
 	ecc = platform_get_drvdata(pdev);
 	clk_prepare_enable(ecc->clk);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 6 lines · Miaoqian Lin

If of_find_device_by_node() succeeds, ingenic_ecc_get() doesn't have a corresponding put_device(). Thus add put_device() to fix the exception handling.

Fixes 15de8c6 ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")

Cheers,
-Paul

Quoted 28 lines
---
 drivers/mtd/nand/raw/ingenic/ingenic_ecc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/ingenic/ingenic_ecc.c +6 -2
index efe0ffe4f1ab..9054559e52dd 100644
@@ -68,9 +68,14 @@ static struct ingenic_ecc *ingenic_ecc_get(struct 
 device_node *np)
 	struct ingenic_ecc *ecc;
 
 	pdev = of_find_device_by_node(np);
-	if (!pdev || !platform_get_drvdata(pdev))
+	if (!pdev)
 		return ERR_PTR(-EPROBE_DEFER);
 
+	if (!platform_get_drvdata(pdev)) {
+		put_device(&pdev->dev);
+		return ERR_PTR(-EPROBE_DEFER);
+	}
+
 	ecc = platform_get_drvdata(pdev);
 	clk_prepare_enable(ecc->clk);
 
--

2.17.1

maintainer Applied
#2 lore raw
In reply to Miaoqian Lin
Quoted 7 lines · Miaoqian Lin

If of_find_device_by_node() succeeds, ingenic_ecc_get() doesn't have a corresponding put_device(). Thus add put_device() to fix the exception handling.

Fixes 15de8c6 ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

maintainer
#3 lore raw

[email protected] wrote on Sun, 23 Jan 2022 16:23:32 +0100:

Quoted 10 lines · Miaoqian Lin
Quoted 7 lines

If of_find_device_by_node() succeeds, ingenic_ecc_get() doesn't have a corresponding put_device(). Thus add put_device() to fix the exception handling.

Fixes 15de8c6 ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Pushed on mtd/fixes, actually.