Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 87108dc78eb8 ("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>

authored by

Miaoqian Lin and committed by
Krzysztof Kozlowski
6f296a96 b452dbf2

+17 -6
+17 -6
drivers/memory/atmel-ebi.c
··· 544 544 smc_np = of_parse_phandle(dev->of_node, "atmel,smc", 0); 545 545 546 546 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 + } 549 551 550 552 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 + } 553 557 554 558 ebi->smc.clk = of_clk_get(smc_np, 0); 555 559 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 + } 558 564 559 565 ebi->smc.clk = NULL; 560 566 } 567 + of_node_put(smc_np); 561 568 ret = clk_prepare_enable(ebi->smc.clk); 562 569 if (ret) 563 570 return ret; ··· 615 608 } 616 609 617 610 return of_platform_populate(np, NULL, NULL, dev); 611 + 612 + put_node: 613 + of_node_put(smc_np); 614 + return ret; 618 615 } 619 616 620 617 static __maybe_unused int atmel_ebi_resume(struct device *dev)