* [PATCH] bpftool: Fix NULL vs IS_ERR() checking in do_show()
@ 2021-12-12 4:42 Miaoqian Lin
0 siblings, 0 replies; only message in thread
From: Miaoqian Lin @ 2021-12-12 4:42 UTC (permalink / raw)
Cc: linmq006, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Quentin Monnet, Cong Wang, Hengqi Chen, netdev, bpf,
linux-kernel
The hashmap__new() function does not return NULL on errors. It returns
ERR_PTR(-ENOMEM). Using IS_ERR() to check the return value
to fix this.
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
tools/bpf/bpftool/prog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 515d22952602..564a15f881c6 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -571,7 +571,7 @@ static int do_show(int argc, char **argv)
if (show_pinned) {
prog_table = hashmap__new(hash_fn_for_key_as_id,
equal_fn_for_key_as_id, NULL);
- if (!prog_table) {
+ if (IS_ERR(prog_table)) {
p_err("failed to create hashmap for pinned paths");
return -1;
}
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-12 4:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 4:42 [PATCH] bpftool: Fix NULL vs IS_ERR() checking in do_show() Miaoqian Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).