drivers/bus/vexpress-config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
In vexpress_syscfg_probe(), of_parse_phandle() is called inside a loop
but the returned device_node reference is never released.
Fix this by using the __free(device_node) cleanup handler to automatically
release the reference when the variable goes out of scope.
Fixes: a5a38765ac79b ("bus: vexpress-config: simplify config bus probing")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/bus/vexpress-config.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c
index 64ee920721ee..a1fa583e9f5d 100644
--- a/drivers/bus/vexpress-config.c
+++ b/drivers/bus/vexpress-config.c
@@ -4,6 +4,7 @@
* Copyright (C) 2014 ARM Limited
*/
+#include <linux/cleanup.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
@@ -390,9 +391,8 @@ static int vexpress_syscfg_probe(struct platform_device *pdev)
}
for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") {
- struct device_node *bridge_np;
-
- bridge_np = of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
+ struct device_node *bridge_np __free(device_node) =
+ of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
if (bridge_np != pdev->dev.parent->of_node)
continue;
---
base-commit: 053966c344dbd346e71305f530e91ea77916189f
change-id: 20260122-b4-vexpress-config-1d2051861d93
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
Hello,
On Thu, Jan 22, 2026 at 08:33:04PM +0800, Felix Gu wrote:
> In vexpress_syscfg_probe(), of_parse_phandle() is called inside a loop
> but the returned device_node reference is never released.
> Fix this by using the __free(device_node) cleanup handler to automatically
> release the reference when the variable goes out of scope.
>
> Fixes: a5a38765ac79b ("bus: vexpress-config: simplify config bus probing")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> drivers/bus/vexpress-config.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c
> index 64ee920721ee..a1fa583e9f5d 100644
> --- a/drivers/bus/vexpress-config.c
> +++ b/drivers/bus/vexpress-config.c
> @@ -4,6 +4,7 @@
> * Copyright (C) 2014 ARM Limited
> */
>
> +#include <linux/cleanup.h>
Not sure this is needed. of.h includes cleanup.h, so we don't run the risk of
not getting the cleanup macros defined.
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/io.h>
> @@ -390,9 +391,8 @@ static int vexpress_syscfg_probe(struct platform_device *pdev)
> }
>
> for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") {
> - struct device_node *bridge_np;
> -
> - bridge_np = of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
> + struct device_node *bridge_np __free(device_node) =
> + of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
> if (bridge_np != pdev->dev.parent->of_node)
> continue;
>
Otherwise, patch looks good to me. Thanks for the fix!
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Best regards,
Liviu
>
> ---
> base-commit: 053966c344dbd346e71305f530e91ea77916189f
> change-id: 20260122-b4-vexpress-config-1d2051861d93
>
> Best regards,
> --
> Felix Gu <ustc.gu@gmail.com>
>
Hi Liviu,
Thanks for the review.
I will remove the header file and send out V2.
Best regars,
Felix
On Thu, Jan 22, 2026 at 9:32 PM Liviu Dudau <liviu.dudau@arm.com> wrote:
>
> Hello,
>
> On Thu, Jan 22, 2026 at 08:33:04PM +0800, Felix Gu wrote:
> > In vexpress_syscfg_probe(), of_parse_phandle() is called inside a loop
> > but the returned device_node reference is never released.
> > Fix this by using the __free(device_node) cleanup handler to automatically
> > release the reference when the variable goes out of scope.
> >
> > Fixes: a5a38765ac79b ("bus: vexpress-config: simplify config bus probing")
> > Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> > ---
> > drivers/bus/vexpress-config.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c
> > index 64ee920721ee..a1fa583e9f5d 100644
> > --- a/drivers/bus/vexpress-config.c
> > +++ b/drivers/bus/vexpress-config.c
> > @@ -4,6 +4,7 @@
> > * Copyright (C) 2014 ARM Limited
> > */
> >
> > +#include <linux/cleanup.h>
>
> Not sure this is needed. of.h includes cleanup.h, so we don't run the risk of
> not getting the cleanup macros defined.
>
> > #include <linux/err.h>
> > #include <linux/init.h>
> > #include <linux/io.h>
> > @@ -390,9 +391,8 @@ static int vexpress_syscfg_probe(struct platform_device *pdev)
> > }
> >
> > for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") {
> > - struct device_node *bridge_np;
> > -
> > - bridge_np = of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
> > + struct device_node *bridge_np __free(device_node) =
> > + of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
> > if (bridge_np != pdev->dev.parent->of_node)
> > continue;
> >
>
> Otherwise, patch looks good to me. Thanks for the fix!
>
> Acked-by: Liviu Dudau <liviu.dudau@arm.com>
>
> Best regards,
> Liviu
>
> >
> > ---
> > base-commit: 053966c344dbd346e71305f530e91ea77916189f
> > change-id: 20260122-b4-vexpress-config-1d2051861d93
> >
> > Best regards,
> > --
> > Felix Gu <ustc.gu@gmail.com>
> >
© 2016 - 2026 Red Hat, Inc.