dma-contiguous: check for memory region overlap
authorBinglei Wang <l3b2w1@gmail.com>
Wed, 26 Jul 2023 14:28:23 +0000 (22:28 +0800)
committerChristoph Hellwig <hch@lst.de>
Mon, 31 Jul 2023 15:54:56 +0000 (17:54 +0200)
In the process of parsing the DTS, check whether the memory region
specified by the DTS CMA node area overlaps with the kernel text
memory space reserved by memblock before calling
early_init_fdt_scan_reserved_mem.

Signed-off-by: Binglei Wang <l3b2w1@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/contiguous.c

index f005c66f378c32e9bae2d84b0ca80d1c126f0c15..88c595e49e3452b0a252c40af595c9b2ff39b293 100644 (file)
@@ -473,6 +473,11 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
                return -EBUSY;
        }
 
+       if (memblock_is_region_reserved(rmem->base, rmem->size)) {
+               pr_info("Reserved memory: overlap with other memblock reserved region\n");
+               return -EBUSY;
+       }
+
        if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
            of_get_flat_dt_prop(node, "no-map", NULL))
                return -EINVAL;