x86/boot: fix boot decompressor malloc() prototype for GCC builtins Signed-off-by: redacherkaoui <[email protected]>
PATCH 1/1 x86/boot: fix boot decompressor malloc() prototype for GCC builtins Signed-off-by: redacherkaoui <[email protected]>
--- arch/x86/boot/compressed/misc.h | 11 ++++++++++- include/linux/decompress/mm.h | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-)
arch/x86/boot/compressed/misc.h +10 -1
@@ -61,7 +61,16 @@ extern char _head[], _end[];extern memptr free_mem_ptr;extern memptr free_mem_end_ptr;extern int spurious_nmi_count; -void *malloc (int size); + +/* +* boot/compressed uses the tiny allocator from include/linux/decompress/mm.h. +* Name is "malloc" but it is *not* libc malloc(). +* +* Keep this prototype in sync with mm.h. Use unsigned long to match the +* compiler builtin signature on x86_64 (size_t == unsigned long). +*/ +void *malloc (unsigned long size); +void free (void *where);void __putstr (const char *s);void __puthex (unsigned long value);
include/linux/decompress/mm.h +7 -3
@@ -39,12 +39,16 @@STATIC_RW_DATA unsigned long malloc_ptr; STATIC_RW_DATA int malloc_count; -MALLOC_VISIBLE void *malloc(int size) +MALLOC_VISIBLE void *malloc(unsigned long size) {void *p; -if (size <0 ) -return NULL ; +/* +* This is a tiny pre-boot allocator; callers should never pass a +* negative size. Use an unsigned type to match compiler builtin +* expectations (size_t on x86_64 is unsigned long) and avoid +* -Wbuiltin-declaration-mismatch under -Werror. +*/ if (!malloc_ptr) malloc_ptr = free_mem_ptr;
Signature · 1 line
2.43.0