]> git.99rst.org Git - openwrt-packages.git/commitdiff
batman-adv: fix build against kernels backporting kmalloc_obj
authorJosef Schlehofer <redacted>
Thu, 6 Aug 2026 12:43:25 +0000 (14:43 +0200)
committerJosef Schlehofer <redacted>
Tue, 18 Aug 2026 08:04:02 +0000 (10:04 +0200)
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 <redacted>
Co-authored-by: Claude Fable 5 <redacted>
net/batman-adv/src/compat-hacks.h

index 0cfaf63715407c539142677c86aac93d315a749a..43cce807913775195b07f50f9627337e3cd8f287 100644 (file)
@@ -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 <linux/slab.h>
 
+#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) */
 
git clone https://git.99rst.org/PROJECT