From: Josef Schlehofer Date: Thu, 6 Aug 2026 12:43:25 +0000 (+0200) Subject: batman-adv: fix build against kernels backporting kmalloc_obj X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=53bafc09a375230009552845a86005148b57c73c;p=openwrt-packages.git batman-adv: fix build against kernels backporting kmalloc_obj The compat definitions of kzalloc_obj(), kmalloc_obj() and kmalloc_objs() were guarded by a version range which carves out only specific stable backports. These helpers are backported on demand to stable kernel branches, so on a newer stable kernel they collide with the definitions in include/linux/slab.h and the module fails to build: compat-hacks.h:52:9: error: "kzalloc_obj" redefined [-Werror] ./include/linux/slab.h:963:9: note: this is the location of the previous definition CI showed this on exactly the four targets sitting on KERNEL_PATCHVER 6.12 - mips_24kc, powerpc_8548, arm_cortex-a15 and arm_cortex-a9 - while the six 6.18 targets passed. Guard each definition on the macro name instead, so the compat code steps aside whenever the kernel provides the helper, without having to track which point release of which stable series picked up the backport. This mirrors what batman-adv carries in compat-include/linux/slab.h. That file is not used by this package, which force-includes its own compat-hacks.h instead, so the same fix has to be applied here as well. slab.h is included explicitly, because unlike the upstream file this header does not otherwise pull it in. Upstream-Status: Backport [96a26bababe5e9c9b9f9226e7cdbe60f49f57b71] Signed-off-by: Josef Schlehofer Co-authored-by: Claude Fable 5 --- diff --git a/net/batman-adv/src/compat-hacks.h b/net/batman-adv/src/compat-hacks.h index 0cfaf6371..43cce8079 100644 --- a/net/batman-adv/src/compat-hacks.h +++ b/net/batman-adv/src/compat-hacks.h @@ -46,17 +46,24 @@ static inline u32 batadv_skb_crc32c(struct sk_buff *skb, int offset, #endif /* LINUX_VERSION_IS_LESS(6, 16, 0) || !defined(CONFIG_NET_CRC32C) */ -#if LINUX_VERSION_IS_LESS(7, 0, 0) && \ - !(LINUX_VERSION_IS_GEQ(6, 18, 33) && LINUX_VERSION_IS_LESS(6, 19, 0)) +#include +#if LINUX_VERSION_IS_LESS(7, 0, 0) + +#ifndef kzalloc_obj #define kzalloc_obj(P, GFP) \ kzalloc(sizeof(P), GFP) +#endif /* kzalloc_obj */ +#ifndef kmalloc_obj #define kmalloc_obj(P, GFP) \ kmalloc(sizeof(P), GFP) +#endif /* kmalloc_obj */ +#ifndef kmalloc_objs #define kmalloc_objs(P, COUNT, GFP) \ kmalloc_array((COUNT), sizeof(P), GFP) +#endif /* kmalloc_objs */ #endif /* < KERNEL_VERSION(7, 0, 0) */