Linux ACPI
 help / color / mirror / Atom feed
* [PATCH] ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint()
@ 2025-11-11  7:50 Haotian Zhang
  2025-11-12 13:48 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Haotian Zhang @ 2025-11-11  7:50 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, linux-kernel, Haotian Zhang

acpi_fwnode_graph_parse_endpoint() calls fwnode_get_parent() to obtain the
parent fwnode but returns without calling fwnode_handle_put() on it. This
leads to a fwnode refcount leak and prevents the parent node from being
released properly.

Call fwnode_handle_put() on the parent fwnode before returning to
fix the leak.

Fixes: 3b27d00e7b6d ("device property: Move fwnode graph ops to firmware specific locations")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/acpi/property.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 1b997a5497e7..7f8790e8dc4e 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1714,6 +1714,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 	if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
 		fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
 
+	fwnode_handle_put(port_fwnode);
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint()
  2025-11-11  7:50 [PATCH] ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint() Haotian Zhang
@ 2025-11-12 13:48 ` Rafael J. Wysocki
  2025-11-12 14:42   ` Sakari Ailus
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2025-11-12 13:48 UTC (permalink / raw)
  To: Haotian Zhang, Sakari Ailus, Andy Shevchenko; +Cc: linux-acpi, linux-kernel

On Tue, Nov 11, 2025 at 8:50 AM Haotian Zhang <vulab@iscas.ac.cn> wrote:
>
> acpi_fwnode_graph_parse_endpoint() calls fwnode_get_parent() to obtain the
> parent fwnode but returns without calling fwnode_handle_put() on it. This
> leads to a fwnode refcount leak and prevents the parent node from being
> released properly.
>
> Call fwnode_handle_put() on the parent fwnode before returning to
> fix the leak.
>
> Fixes: 3b27d00e7b6d ("device property: Move fwnode graph ops to firmware specific locations")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
>  drivers/acpi/property.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 1b997a5497e7..7f8790e8dc4e 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -1714,6 +1714,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
>         if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
>                 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
>
> +       fwnode_handle_put(port_fwnode);
>         return 0;
>  }
>
> --

Andy, Sakari, this looks like a genuine fix to me, any comments?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint()
  2025-11-12 13:48 ` Rafael J. Wysocki
@ 2025-11-12 14:42   ` Sakari Ailus
  2025-11-12 20:25     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2025-11-12 14:42 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Haotian Zhang, Andy Shevchenko, linux-acpi, linux-kernel

Hi Rafael, Haotian,

On Wed, Nov 12, 2025 at 02:48:30PM +0100, Rafael J. Wysocki wrote:
> On Tue, Nov 11, 2025 at 8:50 AM Haotian Zhang <vulab@iscas.ac.cn> wrote:
> >
> > acpi_fwnode_graph_parse_endpoint() calls fwnode_get_parent() to obtain the
> > parent fwnode but returns without calling fwnode_handle_put() on it. This
> > leads to a fwnode refcount leak and prevents the parent node from being
> > released properly.
> >
> > Call fwnode_handle_put() on the parent fwnode before returning to
> > fix the leak.
> >
> > Fixes: 3b27d00e7b6d ("device property: Move fwnode graph ops to firmware specific locations")
> > Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> > ---
> >  drivers/acpi/property.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> > index 1b997a5497e7..7f8790e8dc4e 100644
> > --- a/drivers/acpi/property.c
> > +++ b/drivers/acpi/property.c
> > @@ -1714,6 +1714,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
> >         if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
> >                 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
> >
> > +       fwnode_handle_put(port_fwnode);

I'd add a newline here.

> >         return 0;
> >  }
> >
> > --
> 
> Andy, Sakari, this looks like a genuine fix to me, any comments?

Thanks for cc'ing me.

On ACPI fwnode_handle_put() is a nop, and presumably a parent of an ACPI
node is an ACPI node as well. So this doesn't change fwnode refcounting but
is nevertheless a good thing to do for API usage correctness.

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Kind regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint()
  2025-11-12 14:42   ` Sakari Ailus
@ 2025-11-12 20:25     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2025-11-12 20:25 UTC (permalink / raw)
  To: Sakari Ailus, Haotian Zhang; +Cc: Andy Shevchenko, linux-acpi, linux-kernel

On Wed, Nov 12, 2025 at 3:42 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> Hi Rafael, Haotian,
>
> On Wed, Nov 12, 2025 at 02:48:30PM +0100, Rafael J. Wysocki wrote:
> > On Tue, Nov 11, 2025 at 8:50 AM Haotian Zhang <vulab@iscas.ac.cn> wrote:
> > >
> > > acpi_fwnode_graph_parse_endpoint() calls fwnode_get_parent() to obtain the
> > > parent fwnode but returns without calling fwnode_handle_put() on it. This
> > > leads to a fwnode refcount leak and prevents the parent node from being
> > > released properly.
> > >
> > > Call fwnode_handle_put() on the parent fwnode before returning to
> > > fix the leak.
> > >
> > > Fixes: 3b27d00e7b6d ("device property: Move fwnode graph ops to firmware specific locations")
> > > Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> > > ---
> > >  drivers/acpi/property.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> > > index 1b997a5497e7..7f8790e8dc4e 100644
> > > --- a/drivers/acpi/property.c
> > > +++ b/drivers/acpi/property.c
> > > @@ -1714,6 +1714,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
> > >         if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
> > >                 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
> > >
> > > +       fwnode_handle_put(port_fwnode);
>
> I'd add a newline here.
>
> > >         return 0;
> > >  }
> > >
> > > --
> >
> > Andy, Sakari, this looks like a genuine fix to me, any comments?
>
> Thanks for cc'ing me.
>
> On ACPI fwnode_handle_put() is a nop, and presumably a parent of an ACPI
> node is an ACPI node as well. So this doesn't change fwnode refcounting but
> is nevertheless a good thing to do for API usage correctness.
>
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

OK, applied as 6.19 material, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-12 20:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11  7:50 [PATCH] ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint() Haotian Zhang
2025-11-12 13:48 ` Rafael J. Wysocki
2025-11-12 14:42   ` Sakari Ailus
2025-11-12 20:25     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox