From 5edf5e5585fa022c0399c7b5ccf5a36476dad4c5 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sat, 21 May 2022 08:13:09 +0900 Subject: [PATCH] mm: Add CONFIG_MM_PANIC_ON_FAILURE option While allocation failure here is not necessarily abnormal enough to warrant a panic in general, it can be useful in certain situations. --- mm/Kconfig | 5 +++++ mm/mm_heap/mm_malloc.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/mm/Kconfig b/mm/Kconfig index 30e789da5b9..d49409611ba 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -201,4 +201,9 @@ config MM_DUMP_ON_FAILURE default n depends on DEBUG_MM +config MM_PANIC_ON_FAILURE + bool "Panic on allocation failure" + default n + depends on DEBUG_MM + source "mm/iob/Kconfig" diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index a5fd14b5283..1d8d6b24bc0 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -255,6 +255,9 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) minfo.arena, minfo.uordblks, minfo.fordblks, minfo.mxordblk, minfo.aordblks, minfo.ordblks); mm_memdump(heap, -1); +#endif +#ifdef CONFIG_MM_PANIC_ON_FAILURE + PANIC(); #endif } #endif