[PATCH 1/2] bpf: Fix register_bpf_struct_ops() dummy

From: Geert Uytterhoeven

Date: Thu Dec 04 2025 - 05:29:32 EST


If CONFIG_BPF_SYSCALL=y, but CONFIG_BPF_JIT=n:

net/smc/smc_hs_bpf.c: In function ‘bpf_smc_hs_ctrl_init’:
include/linux/bpf.h:2068:50: error: statement with no effect [-Werror=unused-value]
2068 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
| ^~~~~~~~~~~~~~~~
net/smc/smc_hs_bpf.c:139:16: note: in expansion of macro ‘register_bpf_struct_ops’
139 | return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl);
| ^~~~~~~~~~~~~~~~~~~~~~~

As type is not a variable, but a variable type, this cannot be fixed by
just converting register_bpf_struct_ops() into a static inline function.
Hence fix this by introducing a static inline intermediate dummy.

Fixes: f6be98d19985411c ("bpf, net: switch to dynamic registration")
Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
---
include/linux/bpf.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 6498be4c44f8c275..bb69905c28a761e7 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2065,7 +2065,11 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc,
void bpf_map_struct_ops_info_fill(struct bpf_map_info *info, struct bpf_map *map);
void bpf_struct_ops_desc_release(struct bpf_struct_ops_desc *st_ops_desc);
#else
-#define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
+static inline int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops)
+{
+ return 0;
+}
+#define register_bpf_struct_ops(st_ops, type) __register_bpf_struct_ops(st_ops)
static inline bool bpf_try_module_get(const void *data, struct module *owner)
{
return try_module_get(owner);
--
2.43.0