Subject: [PATCH RESEND] 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.

Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
Reviewed-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Mohammad Shehar Yaar Tausif <[email protected]>
---
- already merged in linux-next
- [1] suggested sending as a fix for 6.10 cycle

[1] https://lore.kernel.org/all/[email protected]/
---
kernel/bpf/bpf_local_storage.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
index 976cb258a0ed..c938dea5ddbf 100644
--- a/kernel/bpf/bpf_local_storage.c
+++ b/kernel/bpf/bpf_local_storage.c
@@ -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;

---
base-commit: 2ef5971ff345d3c000873725db555085e0131961
change-id: 20240612-master-fe9e63ab5c95

Best regards,
--
Mohammad Shehar Yaar Tausif <[email protected]>



2024-06-12 14:56:19

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc

On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
<[email protected]> wrote:
>
> The original function call passed size of smap->bucket before the number of
> buckets which raises the error 'calloc-transposed-args' on compilation.
>
> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
> Reviewed-by: Andrii Nakryiko <[email protected]>
> Signed-off-by: Mohammad Shehar Yaar Tausif <[email protected]>
> ---
> - already merged in linux-next
> - [1] suggested sending as a fix for 6.10 cycle

No. It's not a fix.

pw-bot: cr

>
> [1] https://lore.kernel.org/all/[email protected]/
> ---
> kernel/bpf/bpf_local_storage.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
> index 976cb258a0ed..c938dea5ddbf 100644
> --- a/kernel/bpf/bpf_local_storage.c
> +++ b/kernel/bpf/bpf_local_storage.c
> @@ -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;
>
> ---
> base-commit: 2ef5971ff345d3c000873725db555085e0131961
> change-id: 20240612-master-fe9e63ab5c95
>
> Best regards,
> --
> Mohammad Shehar Yaar Tausif <[email protected]>
>