bpf: Fix order of args in call to bpf_map_kvcalloc
authorMohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
Thu, 16 May 2024 07:24:11 +0000 (12:54 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 18 May 2024 17:46:16 +0000 (10:46 -0700)
The original function call passed size of smap->bucket before the number of
buckets which raises the error 'calloc-transposed-args' on compilation.

Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240516072411.42016-1-sheharyaar48@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/bpf_local_storage.c

index 976cb25..c938dea 100644 (file)
@@ -782,8 +782,8 @@ bpf_local_storage_map_alloc(union bpf_attr *attr,
        nbuckets = max_t(u32, 2, nbuckets);
        smap->bucket_log = ilog2(nbuckets);
 
-       smap->buckets = bpf_map_kvcalloc(&smap->map, sizeof(*smap->buckets),
-                                        nbuckets, GFP_USER | __GFP_NOWARN);
+       smap->buckets = bpf_map_kvcalloc(&smap->map, nbuckets,
+                                        sizeof(*smap->buckets), GFP_USER | __GFP_NOWARN);
        if (!smap->buckets) {
                err = -ENOMEM;
                goto free_smap;