Skip to contentSkip to conversation

libbpf: fix return value on memory allocation failure

PATCH Applied Ben Gardon 2 participants 2 messages Dec 2 – Dec 3

Subsystems (2)
lore
Share & tools
lore

Ben Gardon

author
#0 lore raw

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

---
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
index fb8a1f07c5b6..e47544c4a0d2 100644
@@ -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
#1 lore raw
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 -EINVAL instead of -ENOMEM on the memory allocation failure. Fix it.

Fixes 590a00888250 ("bpf: libbpf: Add STRUCT_OPS support")

[...]

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