Skip to contentSkip to conversation

ACPI: property: Release subnode properties with data nodes

PATCH Applied Sakari Ailus 3 participants 3 messages Apr 6, 2022 – Apr 13, 2022 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: property: Release subnode properties with data nodes

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 [email protected] (for v4.20 and up)
---
 drivers/acpi/property.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/acpi/property.c +12 -6
index 3fceb4681ec9f..2da5e7cd28134 100644
@@ -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);
 }
 
 /**
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Sakari Ailus

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.

Quoted 56 lines
Fixes 5f5e4890d57a ("ACPI / property: Allow multiple property compatible _DSD entries")
Cc [email protected] (for v4.20 and up)
---
 drivers/acpi/property.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/acpi/property.c +12 -6
index 3fceb4681ec9f..2da5e7cd28134 100644
@@ -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);
 }
 
 /**
Signature · 1 line
2.30.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#2 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Sakari Ailus

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.

Applied as 5.19 material, thanks!

Quoted 54 lines
Quoted 54 lines
Fixes 5f5e4890d57a ("ACPI / property: Allow multiple property compatible _DSD entries")
Cc [email protected] (for v4.20 and up)
---
 drivers/acpi/property.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/acpi/property.c +12 -7
index 3fceb4681ec9f..2da5e7cd28134 100644
@@ -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);
 }
 
 /**
--