Skip to contentSkip to conversation

ACPI: property: Fix error handling in acpi_init_properties()

PATCH Applied Sakari Ailus 2 participants 2 messages Aug 8, 2022 – Aug 9, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: property: Fix error handling in acpi_init_properties()

buf.pointer, memory for storing _DSD data and nodes, was released if either parsing properties or, as recently added, attaching data node tags failed. Alas, properties were still left pointing to this memory if parsing properties were successful but attaching data node tags failed.

Fix this by separating error handling for the two, and leaving properties intact if data nodes cannot be tagged for a reason or another.

Fixes 1d52f10917a7 ("ACPI: property: Tie data nodes to acpi handles")

---
Hi Rafael,

This should fix the immediate problem. It needs to be figured out why data node tagging doesn't work sometimes but that can wait.

 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +4 -4
index 9711482014a6..201a5a9b2671 100644
@@ -566,13 +566,13 @@ void acpi_init_properties(struct acpi_device *adev)
 					&adev->data, acpi_fwnode_handle(adev)))
 		adev->data.pointer = buf.pointer;
 
-	if (!adev->data.pointer ||
-	    !acpi_tie_nondev_subnodes(&adev->data)) {
-		acpi_untie_nondev_subnodes(&adev->data);
+	if (!adev->data.pointer) {
 		acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n");
 		ACPI_FREE(buf.pointer);
+	} else {
+		if (!acpi_tie_nondev_subnodes(&adev->data))
+			acpi_untie_nondev_subnodes(&adev->data);
 	}
-
  out:
 	if (acpi_of && !adev->flags.of_compatible_ok)
 		acpi_handle_info(adev->handle,
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 9 lines · Sakari Ailus

buf.pointer, memory for storing _DSD data and nodes, was released if either parsing properties or, as recently added, attaching data node tags failed. Alas, properties were still left pointing to this memory if parsing properties were successful but attaching data node tags failed.

Fix this by separating error handling for the two, and leaving properties intact if data nodes cannot be tagged for a reason or another.

Quoted 8 lines
Fixes 1d52f10917a7 ("ACPI: property: Tie data nodes to acpi handles")

---
Hi Rafael,

This should fix the immediate problem. It needs to be figured out why data node tagging doesn't work sometimes but that can wait.

Applied, but ->

Quoted 12 lines
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +0 -1
index 9711482014a6..201a5a9b2671 100644
@@ -566,13 +566,13 @@ void acpi_init_properties(struct acpi_device *adev)
                                        &adev->data, acpi_fwnode_handle(adev)))
                adev->data.pointer = buf.pointer;
 
-       if (!adev->data.pointer ||

drivers/acpi/property.c void acpi_init_properties(struct acpi_device *adev) · line 575

Quoted 10 lines
drivers/acpi/property.c +4 -3
-           !acpi_tie_nondev_subnodes(&adev->data)) {
-               acpi_untie_nondev_subnodes(&adev->data);
+       if (!adev->data.pointer) {
                acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n");
                ACPI_FREE(buf.pointer);
+       } else {
+               if (!acpi_tie_nondev_subnodes(&adev->data))
+                       acpi_untie_nondev_subnodes(&adev->data);
        }
-

-> dropped this empty line removal which is unrelated to the fix (and the empty line is there on purpose).

drivers/acpi/property.c void acpi_init_properties(struct acpi_device *adev)

Quoted 4 lines
drivers/acpi/property.c +0 -1
  out:
        if (acpi_of && !adev->flags.of_compatible_ok)
                acpi_handle_info(adev->handle,
--

Please note that I will not be able to push things after Thursday this week and throughout the next week, so either this goes in on Thursday or it will miss 5.20, in which case sorry about that. We'll see.

Thanks!