BPF List
 help / color / mirror / Atom feed
* [PATCH bpf] libbpf: fix return value on memory allocation failure
@ 2026-12-02 18:06 Ben Gardon
  2026-12-03  3:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Gardon @ 2026-12-02 18:06 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai, Roman Gushchin, Yafang Shao, bpf, linux-kernel,
	Ben Gardon

From: Roman Gushchin <roman.gushchin@linux.dev>

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 <roman.gushchin@linux.dev>
Acked-by: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: Ben Gardon <bgardon@google.com>
---
Split out from the BPF OOM series as a standalone fix.
v3: https://lore.kernel.org/all/20260127024421.494929-4-roman.gushchin@linux.dev/

 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index fb8a1f07c5b6..e47544c4a0d2 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -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);
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf] libbpf: fix return value on memory allocation failure
  2026-12-02 18:06 [PATCH bpf] libbpf: fix return value on memory allocation failure Ben Gardon
@ 2026-12-03  3:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-03  3:40 UTC (permalink / raw)
  To: Ben Gardon
  Cc: ast, daniel, andrii, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, roman.gushchin,
	laoar.shao, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Wed,  2 Dec 2026 10:06:59 -0800 you wrote:
> From: Roman Gushchin <roman.gushchin@linux.dev>
> 
> 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 <roman.gushchin@linux.dev>
> Acked-by: Yafang Shao <laoar.shao@gmail.com>
> Signed-off-by: Ben Gardon <bgardon@google.com>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03  3:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 18:06 [PATCH bpf] libbpf: fix return value on memory allocation failure Ben Gardon
2026-12-03  3:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox