[Sound-open-firmware] [PATCH] alloc: add sanity check for malformed images.

Liam Girdwood liam.r.girdwood at linux.intel.com
Wed Feb 21 18:26:26 CET 2018


Add a sanity check to make sure that data/rodata contains expected values
otherwise this can cause unpredictable behaviour that is difficult to
later diagnose.

Signed-off-by: Liam Girdwood <liam.r.girdwood at linux.intel.com>
---
 src/lib/alloc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lib/alloc.c b/src/lib/alloc.c
index 847cb93..1ae0c91 100644
--- a/src/lib/alloc.c
+++ b/src/lib/alloc.c
@@ -646,6 +646,10 @@ void init_heap(struct reef *reef)
 	struct block_map *current_map;
 	int i;
 
+	/* sanity check for malformed images or loader issues */
+	if (memmap.system.heap != HEAP_SYSTEM_BASE)
+		panic(PANIC_MEM);
+
 	spinlock_init(&memmap.lock);
 
 	/* initialise buffer map */
-- 
2.14.1



More information about the Sound-open-firmware mailing list