Skip to content

Commit af253ae

Browse files
sheharyaarAlexei Starovoitov
authored andcommitted
bpf: fix order of args in call to bpf_map_kvcalloc
The original function call passed size of smap->bucket before the number of buckets which raises the error 'calloc-transposed-args' on compilation. Vlastimil Babka added: The order of parameters can be traced back all the way to 6ac99e8 ("bpf: Introduce bpf sk local storage") accross several refactorings, and that's why the commit is used as a Fixes: tag. In v6.10-rc1, a different commit 2c321f3 ("mm: change inlined allocation helpers to account at the call site") however exposed the order of args in a way that gcc-14 has enough visibility to start warning about it, because (in !CONFIG_MEMCG case) bpf_map_kvcalloc is then a macro alias for kvcalloc instead of a static inline wrapper. To sum up the warning happens when the following conditions are all met: - gcc-14 is used (didn't see it with gcc-13) - commit 2c321f3 is present - CONFIG_MEMCG is not enabled in .config - CONFIG_WERROR turns this from a compiler warning to error Fixes: 6ac99e8 ("bpf: Introduce bpf sk local storage") Reviewed-by: Andrii Nakryiko <[email protected]> Tested-by: Christian Kujau <[email protected]> Signed-off-by: Mohammad Shehar Yaar Tausif <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent e1533b6 commit af253ae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/bpf_local_storage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,8 @@ bpf_local_storage_map_alloc(union bpf_attr *attr,
782782
nbuckets = max_t(u32, 2, nbuckets);
783783
smap->bucket_log = ilog2(nbuckets);
784784

785-
smap->buckets = bpf_map_kvcalloc(&smap->map, sizeof(*smap->buckets),
786-
nbuckets, GFP_USER | __GFP_NOWARN);
785+
smap->buckets = bpf_map_kvcalloc(&smap->map, nbuckets,
786+
sizeof(*smap->buckets), GFP_USER | __GFP_NOWARN);
787787
if (!smap->buckets) {
788788
err = -ENOMEM;
789789
goto free_smap;

0 commit comments

Comments
 (0)