手贱开启CONFIG_DEBUG_KMEMLEAK宏去定位内存泄漏问题。
CONFIG_DEBUG_PAGEALLOC=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=n
CONFIG_DEBUG_STACK_USAGE=y
CONFIG_DEBUG_MEMORY_INIT=y
CONFIG_PANIC_ON_RECURSIVE_FAULT=y
问题没定位出来,竟然出现了panic------回溯报告写起。
好吧,划水王啥都不会,但捅出来的篓子还是要补一补,话说内事不决问百度,外事不决问谷歌,来附上修改方法和找出来的补丁
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 78aa9eb..908e2a2 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -34,22 +34,15 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end;
align = !align ? SMP_CACHE_BYTES : align;
- base = memblock_phys_alloc_range(size, align, 0, end);
+ base = memblock_find_in_range(size, align, start, end);
if (!base)
return -ENOMEM;
- /*
- * Check if the allocated region fits in to start..end window
- */
- if (base < start) {
- memblock_free(base, size);
- return -ENOMEM;
- }
-
*res_base = base;
if (nomap)
return memblock_remove(base, size);
- return 0;
+
+ return memblock_reserve(base, size);
}
/**
补丁路径
[v3] of: fix kmemleak crash caused by imbalance in early memory reservation - Patchwork
另外补充一点,如果该修改方法出现宏命名不规范、宏使用不规范、返回值不规范和代码逻辑有问题,请找划水王。