Skip to contentSkip to conversation

tools/bpftool: fix error return value in build_btf_type_table()

PATCH Applied Zhen Lei 3 participants 3 messages Nov 24, 2020

Subsystems (4)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 tools/bpftool: fix error return value in build_btf_type_table()

An appropriate return value should be set on the failed path.

---
 tools/bpf/bpftool/btf.c | 1 +
 1 file changed, 1 insertion(+)
tools/bpf/bpftool/btf.c +1 -0
index 8ab142ff5eac..2afb7d5b1aca 100644
@@ -693,6 +693,7 @@ build_btf_type_table(struct btf_attach_table *tab, enum bpf_obj_type type,
 		obj_node = calloc(1, sizeof(*obj_node));
 		if (!obj_node) {
 			p_err("failed to allocate memory: %s", strerror(errno));
+			err = -ENOMEM;
 			goto err_free;
 		}
 
Signature · 1 line
2.26.0.106.g9fadedd
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Zhen Lei

An appropriate return value should be set on the failed path.

LGTM.

Also this is a bug fix. It should probably be targeted to bpf tree. So,

Fixes 4d374ba0bf30 ("tools: bpftool: implement "bpftool btf show|list"")
Quoted 17 lines
---
  tools/bpf/bpftool/btf.c | 1 +
  1 file changed, 1 insertion(+)
tools/bpf/bpftool/btf.c +1 -0
index 8ab142ff5eac..2afb7d5b1aca 100644
@@ -693,6 +693,7 @@ build_btf_type_table(struct btf_attach_table *tab, enum bpf_obj_type type,
  		obj_node = calloc(1, sizeof(*obj_node));
  		if (!obj_node) {
  			p_err("failed to allocate memory: %s", strerror(errno));
+			err = -ENOMEM;
  			goto err_free;
  		}
 
#2 lore raw
In reply to Zhen Lei
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

Quoted 7 lines · On Tue, 24 Nov 2020 18:41:00 +0800 you wrote:

An appropriate return value should be set on the failed path.

---
 tools/bpf/bpftool/btf.c | 1 +
 1 file changed, 1 insertion(+)

Here is the summary with links:
- [1/1] tools/bpftool: fix error return value in build_btf_type_table()

    https://git.kernel.org/bpf/bpf/c/68878a5c5b85

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html