]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers
authorFelix Gu <ustc.gu@gmail.com>
Tue, 27 Jan 2026 18:23:12 +0000 (02:23 +0800)
committerLinus Walleij <linusw@kernel.org>
Tue, 3 Feb 2026 00:28:59 +0000 (01:28 +0100)
of_parse_phandle_with_fixed_args() increments the reference count of the
returned device node, so it must be explicitly released using
of_node_put() after use.

Fix the reference leak in aml_bank_pins() and aml_bank_number() by
adding the missing of_node_put() calls.

Fixes: 6e9be3abb78c ("pinctrl: Add driver support for Amlogic SoCs")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
drivers/pinctrl/meson/pinctrl-amlogic-a4.c

index ded7b218e2ec72050b661299552070c96b0cc9a5..40542edd557e0b6a19623accfc91b6a50c7b891c 100644 (file)
@@ -725,8 +725,9 @@ static u32 aml_bank_pins(struct device_node *np)
        if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
                                             0, &of_args))
                return 0;
-       else
-               return of_args.args[2];
+
+       of_node_put(of_args.np);
+       return of_args.args[2];
 }
 
 static int aml_bank_number(struct device_node *np)
@@ -736,8 +737,9 @@ static int aml_bank_number(struct device_node *np)
        if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
                                             0, &of_args))
                return -EINVAL;
-       else
-               return of_args.args[1] >> 8;
+
+       of_node_put(of_args.np);
+       return of_args.args[1] >> 8;
 }
 
 static unsigned int aml_count_pins(struct device_node *np)