All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] ACPI: property: Release subnode properties with data nodes
@ 2022-04-06 13:12 Sakari Ailus
  2022-04-08 12:15 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Sakari Ailus @ 2022-04-06 13:12 UTC (permalink / raw)
  To: linux-acpi; +Cc: rafael.j.wysocki, andriy.shevchenko

struct acpi_device_properties describes one source of properties present
on either struct acpi_device or struct acpi_data_node. When properties are
parsed, both are populated but when released, only those properties that
are associated with the device node are freed.

Fix this by also releasing memory of the data node properties.

Fixes: 5f5e4890d57a ("ACPI / property: Allow multiple property compatible _DSD entries")
Cc: stable@vger.kernel.org (for v4.20 and up)
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/property.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 3fceb4681ec9f..2da5e7cd28134 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -433,6 +433,16 @@ void acpi_init_properties(struct acpi_device *adev)
 		acpi_extract_apple_properties(adev);
 }
 
+static void acpi_free_device_properties(struct list_head *list)
+{
+	struct acpi_device_properties *props, *tmp;
+
+	list_for_each_entry_safe(props, tmp, list, list) {
+		list_del(&props->list);
+		kfree(props);
+	}
+}
+
 static void acpi_destroy_nondev_subnodes(struct list_head *list)
 {
 	struct acpi_data_node *dn, *next;
@@ -445,22 +455,18 @@ static void acpi_destroy_nondev_subnodes(struct list_head *list)
 		wait_for_completion(&dn->kobj_done);
 		list_del(&dn->sibling);
 		ACPI_FREE((void *)dn->data.pointer);
+		acpi_free_device_properties(&dn->data.properties);
 		kfree(dn);
 	}
 }
 
 void acpi_free_properties(struct acpi_device *adev)
 {
-	struct acpi_device_properties *props, *tmp;
-
 	acpi_destroy_nondev_subnodes(&adev->data.subnodes);
 	ACPI_FREE((void *)adev->data.pointer);
 	adev->data.of_compatible = NULL;
 	adev->data.pointer = NULL;
-	list_for_each_entry_safe(props, tmp, &adev->data.properties, list) {
-		list_del(&props->list);
-		kfree(props);
-	}
+	acpi_free_device_properties(&adev->data.properties);
 }
 
 /**
-- 
2.30.2


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

* Re: [PATCH 1/1] ACPI: property: Release subnode properties with data nodes
  2022-04-06 13:12 [PATCH 1/1] ACPI: property: Release subnode properties with data nodes Sakari Ailus
@ 2022-04-08 12:15 ` Andy Shevchenko
  2022-04-13 17:55   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-04-08 12:15 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-acpi, rafael.j.wysocki

On Wed, Apr 06, 2022 at 04:12:08PM +0300, Sakari Ailus wrote:
> struct acpi_device_properties describes one source of properties present
> on either struct acpi_device or struct acpi_data_node. When properties are
> parsed, both are populated but when released, only those properties that
> are associated with the device node are freed.
> 
> Fix this by also releasing memory of the data node properties.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 5f5e4890d57a ("ACPI / property: Allow multiple property compatible _DSD entries")
> Cc: stable@vger.kernel.org (for v4.20 and up)
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/acpi/property.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 3fceb4681ec9f..2da5e7cd28134 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -433,6 +433,16 @@ void acpi_init_properties(struct acpi_device *adev)
>  		acpi_extract_apple_properties(adev);
>  }
>  
> +static void acpi_free_device_properties(struct list_head *list)
> +{
> +	struct acpi_device_properties *props, *tmp;
> +
> +	list_for_each_entry_safe(props, tmp, list, list) {
> +		list_del(&props->list);
> +		kfree(props);
> +	}
> +}
> +
>  static void acpi_destroy_nondev_subnodes(struct list_head *list)
>  {
>  	struct acpi_data_node *dn, *next;
> @@ -445,22 +455,18 @@ static void acpi_destroy_nondev_subnodes(struct list_head *list)
>  		wait_for_completion(&dn->kobj_done);
>  		list_del(&dn->sibling);
>  		ACPI_FREE((void *)dn->data.pointer);
> +		acpi_free_device_properties(&dn->data.properties);
>  		kfree(dn);
>  	}
>  }
>  
>  void acpi_free_properties(struct acpi_device *adev)
>  {
> -	struct acpi_device_properties *props, *tmp;
> -
>  	acpi_destroy_nondev_subnodes(&adev->data.subnodes);
>  	ACPI_FREE((void *)adev->data.pointer);
>  	adev->data.of_compatible = NULL;
>  	adev->data.pointer = NULL;
> -	list_for_each_entry_safe(props, tmp, &adev->data.properties, list) {
> -		list_del(&props->list);
> -		kfree(props);
> -	}
> +	acpi_free_device_properties(&adev->data.properties);
>  }
>  
>  /**
> -- 
> 2.30.2
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/1] ACPI: property: Release subnode properties with data nodes
  2022-04-08 12:15 ` Andy Shevchenko
@ 2022-04-13 17:55   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-04-13 17:55 UTC (permalink / raw)
  To: Andy Shevchenko, Sakari Ailus; +Cc: ACPI Devel Maling List, Rafael Wysocki

On Fri, Apr 8, 2022 at 2:19 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Apr 06, 2022 at 04:12:08PM +0300, Sakari Ailus wrote:
> > struct acpi_device_properties describes one source of properties present
> > on either struct acpi_device or struct acpi_data_node. When properties are
> > parsed, both are populated but when released, only those properties that
> > are associated with the device node are freed.
> >
> > Fix this by also releasing memory of the data node properties.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied as 5.19 material, thanks!

> > Fixes: 5f5e4890d57a ("ACPI / property: Allow multiple property compatible _DSD entries")
> > Cc: stable@vger.kernel.org (for v4.20 and up)
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  drivers/acpi/property.c | 18 ++++++++++++------
> >  1 file changed, 12 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> > index 3fceb4681ec9f..2da5e7cd28134 100644
> > --- a/drivers/acpi/property.c
> > +++ b/drivers/acpi/property.c
> > @@ -433,6 +433,16 @@ void acpi_init_properties(struct acpi_device *adev)
> >               acpi_extract_apple_properties(adev);
> >  }
> >
> > +static void acpi_free_device_properties(struct list_head *list)
> > +{
> > +     struct acpi_device_properties *props, *tmp;
> > +
> > +     list_for_each_entry_safe(props, tmp, list, list) {
> > +             list_del(&props->list);
> > +             kfree(props);
> > +     }
> > +}
> > +
> >  static void acpi_destroy_nondev_subnodes(struct list_head *list)
> >  {
> >       struct acpi_data_node *dn, *next;
> > @@ -445,22 +455,18 @@ static void acpi_destroy_nondev_subnodes(struct list_head *list)
> >               wait_for_completion(&dn->kobj_done);
> >               list_del(&dn->sibling);
> >               ACPI_FREE((void *)dn->data.pointer);
> > +             acpi_free_device_properties(&dn->data.properties);
> >               kfree(dn);
> >       }
> >  }
> >
> >  void acpi_free_properties(struct acpi_device *adev)
> >  {
> > -     struct acpi_device_properties *props, *tmp;
> > -
> >       acpi_destroy_nondev_subnodes(&adev->data.subnodes);
> >       ACPI_FREE((void *)adev->data.pointer);
> >       adev->data.of_compatible = NULL;
> >       adev->data.pointer = NULL;
> > -     list_for_each_entry_safe(props, tmp, &adev->data.properties, list) {
> > -             list_del(&props->list);
> > -             kfree(props);
> > -     }
> > +     acpi_free_device_properties(&adev->data.properties);
> >  }
> >
> >  /**
> > --

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

end of thread, other threads:[~2022-04-13 17:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 13:12 [PATCH 1/1] ACPI: property: Release subnode properties with data nodes Sakari Ailus
2022-04-08 12:15 ` Andy Shevchenko
2022-04-13 17:55   ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.