Skip to content

Commit 6f296a9

Browse files
Yuuoniykrzk
authored andcommitted
memory: atmel-ebi: Fix missing of_node_put in atmel_ebi_probe
The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. Fixes: 87108dc ("memory: atmel-ebi: Enable the SMC clock if specified") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20220309110144.22412-1-linmq006@gmail.com Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent b452dbf commit 6f296a9

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

drivers/memory/atmel-ebi.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,20 +544,27 @@ static int atmel_ebi_probe(struct platform_device *pdev)
544544
smc_np = of_parse_phandle(dev->of_node, "atmel,smc", 0);
545545

546546
ebi->smc.regmap = syscon_node_to_regmap(smc_np);
547-
if (IS_ERR(ebi->smc.regmap))
548-
return PTR_ERR(ebi->smc.regmap);
547+
if (IS_ERR(ebi->smc.regmap)) {
548+
ret = PTR_ERR(ebi->smc.regmap);
549+
goto put_node;
550+
}
549551

550552
ebi->smc.layout = atmel_hsmc_get_reg_layout(smc_np);
551-
if (IS_ERR(ebi->smc.layout))
552-
return PTR_ERR(ebi->smc.layout);
553+
if (IS_ERR(ebi->smc.layout)) {
554+
ret = PTR_ERR(ebi->smc.layout);
555+
goto put_node;
556+
}
553557

554558
ebi->smc.clk = of_clk_get(smc_np, 0);
555559
if (IS_ERR(ebi->smc.clk)) {
556-
if (PTR_ERR(ebi->smc.clk) != -ENOENT)
557-
return PTR_ERR(ebi->smc.clk);
560+
if (PTR_ERR(ebi->smc.clk) != -ENOENT) {
561+
ret = PTR_ERR(ebi->smc.clk);
562+
goto put_node;
563+
}
558564

559565
ebi->smc.clk = NULL;
560566
}
567+
of_node_put(smc_np);
561568
ret = clk_prepare_enable(ebi->smc.clk);
562569
if (ret)
563570
return ret;
@@ -608,6 +615,10 @@ static int atmel_ebi_probe(struct platform_device *pdev)
608615
}
609616

610617
return of_platform_populate(np, NULL, NULL, dev);
618+
619+
put_node:
620+
of_node_put(smc_np);
621+
return ret;
611622
}
612623

613624
static __maybe_unused int atmel_ebi_resume(struct device *dev)

0 commit comments

Comments
 (0)