Skip to contentSkip to conversation

ACPI: resource: Fix memory resource type union access

PATCH Applied Ilpo Järvinen 2 participants 2 messages Dec 2, 2024 – Dec 9, 2024 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: resource: Fix memory resource type union access

In acpi_decode_space() addr->info.mem.caching is checked on main level for any resource type but addr->info.mem is part of union and thus valid only if the resource type is memory range.

Move the check inside the preceeding switch/case to only execute it when the union is of correct type.

Fixes fcb29bbcd540 ("ACPI: Add prefetch decoding to the address space parser")

---

I only came across this while reading code around these parts (not because of investigating some issue).

 drivers/acpi/resource.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/resource.c +3 -3
index 7fe842dae1ec..821867de43be 100644
@@ -250,6 +250,9 @@ static bool acpi_decode_space(struct resource_win *win,
 	switch (addr->resource_type) {
 	case ACPI_MEMORY_RANGE:
 		acpi_dev_memresource_flags(res, len, wp);
+
+		if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
+			res->flags |= IORESOURCE_PREFETCH;
 		break;
 	case ACPI_IO_RANGE:
 		acpi_dev_ioresource_flags(res, len, iodec,
@@ -265,9 +268,6 @@ static bool acpi_decode_space(struct resource_win *win,
 	if (addr->producer_consumer == ACPI_PRODUCER)
 		res->flags |= IORESOURCE_WINDOW;
 
-	if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
-		res->flags |= IORESOURCE_PREFETCH;
-
 	return !(res->flags & IORESOURCE_DISABLED);
 }
 
Signature · 1 line
2.39.5
maintainer Applied
#1 lore raw
Quoted 33 lines · Ilpo Järvinen

In acpi_decode_space() addr->info.mem.caching is checked on main level for any resource type but addr->info.mem is part of union and thus valid only if the resource type is memory range.

Move the check inside the preceeding switch/case to only execute it when the union is of correct type.

Fixes fcb29bbcd540 ("ACPI: Add prefetch decoding to the address space parser")

---

I only came across this while reading code around these parts (not because of investigating some issue).

 drivers/acpi/resource.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/resource.c +3 -0
index 7fe842dae1ec..821867de43be 100644
@@ -250,6 +250,9 @@ static bool acpi_decode_space(struct resource_win *win,
        switch (addr->resource_type) {
        case ACPI_MEMORY_RANGE:
                acpi_dev_memresource_flags(res, len, wp);
+
+               if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
+                       res->flags |= IORESOURCE_PREFETCH;
                break;
        case ACPI_IO_RANGE:
                acpi_dev_ioresource_flags(res, len, iodec,

drivers/acpi/resource.c static bool acpi_decode_space(struct resource_win *win,

Quoted 10 lines
drivers/acpi/resource.c +0 -4
@@ -265,9 +268,6 @@ static bool acpi_decode_space(struct resource_win *win,
        if (addr->producer_consumer == ACPI_PRODUCER)
                res->flags |= IORESOURCE_WINDOW;
 
-       if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
-               res->flags |= IORESOURCE_PREFETCH;
-
        return !(res->flags & IORESOURCE_DISABLED);
 }
 
--

Applied as 6.13-rc material, thanks!