libbpf: fix return value on memory allocation failure
PATCH 1/1 libbpf: fix return value on memory allocation failure
From: Roman Gushchin <[email protected]>
bpf_map__attach_struct_ops() returns -EINVAL instead of -ENOMEM on the memory allocation failure. Fix it.
Fixes 590a00888250 ("bpf: libbpf: Add STRUCT_OPS support")
Signed-off-by Roman Gushchin <[email protected]>
Acked-by Yafang Shao <[email protected]>
Signed-off-by Ben Gardon <[email protected]>
---
Split out from the BPF OOM series as a standalone fix.
v3: https://lore.kernel.org/all/[email protected]/
tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -14724,7 +14724,7 @@ struct bpf_link *bpf_map__attach_struct_ops(const struct bpf_map *map) link =calloc (1 ,sizeof (*link));if (!link) -return libbpf_err_ptr (-EINVAL ); +return libbpf_err_ptr (-ENOMEM );/* kern_vdata should be prepared during the loading phase. */ err =bpf_map_update_elem (map->fd, &zero, map->st_ops->kern_vdata,0 );
Signature · 1 line
2.56.1.911.g883d8bcb20-goog
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 11 lines · On Wed, 2 Dec 2026 10:06:59 -0800 you wrote:
From: Roman Gushchin <[email protected]>
bpf_map__attach_struct_ops()returns-EINVALinstead of-ENOMEMon the memory allocation failure. Fix it.Fixes 590a00888250 ("bpf: libbpf: Add STRUCT_OPS support")Signed-off-by Roman Gushchin <[email protected]>Acked-by Yafang Shao <[email protected]>Signed-off-by Ben Gardon <[email protected]>[...]
Here is the summary with links:
- [bpf] libbpf: fix return value on memory allocation failure
https://git.kernel.org/bpf/bpf-next/c/95d104a5e26f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html