2020-06-01 16:33:15

by Denis Efremov (Oracle)

[permalink] [raw]
Subject: [PATCH] bpf: Change kvfree to kfree in generic_map_lookup_batch()

buf_prevkey in generic_map_lookup_batch() is allocated with
kmalloc(). It's safe to free it with kfree().

Signed-off-by: Denis Efremov <[email protected]>
---
kernel/bpf/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 4e6dee19a668..10bb622be5b6 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1383,7 +1383,7 @@ int generic_map_lookup_batch(struct bpf_map *map,

buf = kmalloc(map->key_size + value_size, GFP_USER | __GFP_NOWARN);
if (!buf) {
- kvfree(buf_prevkey);
+ kfree(buf_prevkey);
return -ENOMEM;
}

--
2.26.2


2020-06-01 20:20:33

by Song Liu

[permalink] [raw]
Subject: Re: [PATCH] bpf: Change kvfree to kfree in generic_map_lookup_batch()

On Mon, Jun 1, 2020 at 9:29 AM Denis Efremov <[email protected]> wrote:
>
> buf_prevkey in generic_map_lookup_batch() is allocated with
> kmalloc(). It's safe to free it with kfree().
>
> Signed-off-by: Denis Efremov <[email protected]>

Please add prefix "PATCH bpf" or "PATCH bpf-next" to indicate which
tree this should
apply to. This one looks more like for bpf-next, as current code still
works. For patches
to bpf-next, we should wait after the merge window.

Also, maybe add:

Fixes: cb4d03ab499d ("bpf: Add generic support for lookup batch op")

Acked-by: Song Liu <[email protected]>

Thanks,
Song

2020-06-01 21:39:58

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH] bpf: Change kvfree to kfree in generic_map_lookup_batch()

On Mon, Jun 1, 2020 at 1:18 PM Song Liu <[email protected]> wrote:
>
> On Mon, Jun 1, 2020 at 9:29 AM Denis Efremov <[email protected]> wrote:
> >
> > buf_prevkey in generic_map_lookup_batch() is allocated with
> > kmalloc(). It's safe to free it with kfree().
> >
> > Signed-off-by: Denis Efremov <[email protected]>
>
> Please add prefix "PATCH bpf" or "PATCH bpf-next" to indicate which
> tree this should
> apply to. This one looks more like for bpf-next, as current code still
> works. For patches
> to bpf-next, we should wait after the merge window.
>
> Also, maybe add:
>
> Fixes: cb4d03ab499d ("bpf: Add generic support for lookup batch op")
>
> Acked-by: Song Liu <[email protected]>

Applied to bpf-next. Thanks