]> Git Repo - linux.git/commitdiff
ACPI: scan: Fix DMA range assignment
authorRobin Murphy <[email protected]>
Tue, 18 Oct 2022 13:14:04 +0000 (14:14 +0100)
committerRafael J. Wysocki <[email protected]>
Wed, 19 Oct 2022 18:27:31 +0000 (20:27 +0200)
Assigning the device's dma_range_map from the iterator variable after
the loop means it always points to the empty terminator at the end of
the map, which is not what we want. Similarly, freeing the iterator on
error when it points to somwhere in the middle of the allocated array
won't work either. Fix this.

Fixes: bf2ee8d0c385 ("ACPI: scan: Support multiple DMA windows with different offsets")
Signed-off-by: Robin Murphy <[email protected]>
Reviewed-by: Jianmin Lv <[email protected]>
Tested-by: Jeremy Linton <[email protected]>
Tested-by: Yicong Yang <[email protected]>
Reviewed-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
drivers/acpi/scan.c

index 558664d169fcc3e10acf1f61f5f24134c97471a4..024cc373a197ff4f9cec081aaadd4c2f9a60abb0 100644 (file)
@@ -1509,9 +1509,12 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
                        goto out;
                }
 
+               *map = r;
+
                list_for_each_entry(rentry, &list, node) {
                        if (rentry->res->start >= rentry->res->end) {
-                               kfree(r);
+                               kfree(*map);
+                               *map = NULL;
                                ret = -EINVAL;
                                dev_dbg(dma_dev, "Invalid DMA regions configuration\n");
                                goto out;
@@ -1523,8 +1526,6 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
                        r->offset = rentry->offset;
                        r++;
                }
-
-               *map = r;
        }
  out:
        acpi_dev_free_resource_list(&list);
This page took 0.051912 seconds and 4 git commands to generate.