diff mbox series

power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe

Message ID 20220523141009.52965-1-linmq006@gmail.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe | expand

Commit Message

Miaoqian Lin May 23, 2022, 2:10 p.m. UTC
of_find_matching_node_and_match() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: 0e545f57b708 ("power: reset: driver for the Versatile syscon reboot")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/power/reset/arm-versatile-reboot.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Linus Walleij May 24, 2022, 7:25 a.m. UTC | #1
On Mon, May 23, 2022 at 4:10 PM Miaoqian Lin <linmq006@gmail.com> wrote:

> of_find_matching_node_and_match() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
>
> Fixes: 0e545f57b708 ("power: reset: driver for the Versatile syscon reboot")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Sebastian Reichel June 9, 2022, 7:14 p.m. UTC | #2
Hi,

On Tue, May 24, 2022 at 09:25:48AM +0200, Linus Walleij wrote:
> On Mon, May 23, 2022 at 4:10 PM Miaoqian Lin <linmq006@gmail.com> wrote:
> 
> > of_find_matching_node_and_match() returns a node pointer with refcount
> > incremented, we should use of_node_put() on it when not need anymore.
> > Add missing of_node_put() to avoid refcount leak.
> >
> > Fixes: 0e545f57b708 ("power: reset: driver for the Versatile syscon reboot")
> > Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Thanks, queued to power-supply's fixes branch.

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/reset/arm-versatile-reboot.c b/drivers/power/reset/arm-versatile-reboot.c
index 08d0a07b58ef..c7624d7611a7 100644
--- a/drivers/power/reset/arm-versatile-reboot.c
+++ b/drivers/power/reset/arm-versatile-reboot.c
@@ -146,6 +146,7 @@  static int __init versatile_reboot_probe(void)
 	versatile_reboot_type = (enum versatile_reboot)reboot_id->data;
 
 	syscon_regmap = syscon_node_to_regmap(np);
+	of_node_put(np);
 	if (IS_ERR(syscon_regmap))
 		return PTR_ERR(syscon_regmap);