Skip to contentSkip to conversation

bpftool: Fix NULL vs IS_ERR() checking in do_show()

PATCH New Miaoqian Lin 1 participant 1 message Dec 12, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpftool: Fix NULL vs IS_ERR() checking in do_show()

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.

---
 tools/bpf/bpftool/prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/bpftool/prog.c +1 -1
index 515d22952602..564a15f881c6 100644
@@ -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;
 		}
Signature · 1 line
2.17.1