Skip to contentSkip to conversation

bpf: Change kvfree to kfree in generic_map_lookup_batch()

PATCH Applied Denis Efremov 3 participants 3 messages Jun 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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().

---
 kernel/bpf/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/syscall.c +1 -1
index 4e6dee19a668..10bb622be5b6 100644
@@ -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;
 	}
 
Signature · 1 line
2.26.2
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Denis Efremov

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

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")

Thanks,
Song

#2 lore raw
Quoted 14 lines · Song Liu
Quoted 5 lines · Denis Efremov

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

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.

Quoted 5 lines

Also, maybe add:

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

Applied to bpf-next. Thanks