Skip to content

Commit 64d23ff

Browse files
rmurphy-armrafaeljw
authored andcommitted
ACPI: scan: Fix DMA range assignment
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: bf2ee8d ("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]>
1 parent 9abf231 commit 64d23ff

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/acpi/scan.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,12 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
15091509
goto out;
15101510
}
15111511

1512+
*map = r;
1513+
15121514
list_for_each_entry(rentry, &list, node) {
15131515
if (rentry->res->start >= rentry->res->end) {
1514-
kfree(r);
1516+
kfree(*map);
1517+
*map = NULL;
15151518
ret = -EINVAL;
15161519
dev_dbg(dma_dev, "Invalid DMA regions configuration\n");
15171520
goto out;
@@ -1523,8 +1526,6 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
15231526
r->offset = rentry->offset;
15241527
r++;
15251528
}
1526-
1527-
*map = r;
15281529
}
15291530
out:
15301531
acpi_dev_free_resource_list(&list);

0 commit comments

Comments
 (0)