All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] tools: bpf: fix NULL return handling in bpf__prepare_load
@ 2018-05-11 11:21 YueHaibing
  2018-05-12 23:20 ` Daniel Borkmann
  0 siblings, 1 reply; 4+ messages in thread
From: YueHaibing @ 2018-05-11 11:21 UTC (permalink / raw)
  To: alexander.shishkin, mingo, peterz; +Cc: netdev, namhyung, YueHaibing

bpf_object__open()/bpf_object__open_buffer can return error pointer or NULL,
check the return values with IS_ERR_OR_NULL() in bpf__prepare_load and
bpf__prepare_load_buffer

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 tools/perf/util/bpf-loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index af7ad81..cee6587 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -66,7 +66,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
 	}
 
 	obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, name);
-	if (IS_ERR(obj)) {
+	if (IS_ERR_OR_NULL(obj)) {
 		pr_debug("bpf: failed to load buffer\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -102,14 +102,14 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
 			pr_debug("bpf: successfull builtin compilation\n");
 		obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, filename);
 
-		if (!IS_ERR(obj) && llvm_param.dump_obj)
+		if (!IS_ERR_OR_NULL(obj) && llvm_param.dump_obj)
 			llvm__dump_obj(filename, obj_buf, obj_buf_sz);
 
 		free(obj_buf);
 	} else
 		obj = bpf_object__open(filename);
 
-	if (IS_ERR(obj)) {
+	if (IS_ERR_OR_NULL(obj)) {
 		pr_debug("bpf: failed to load %s\n", filename);
 		return obj;
 	}
-- 
2.7.0

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

end of thread, other threads:[~2018-05-15 14:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-11 11:21 [PATCH bpf] tools: bpf: fix NULL return handling in bpf__prepare_load YueHaibing
2018-05-12 23:20 ` Daniel Borkmann
2018-05-15 14:11   ` Arnaldo Carvalho de Melo
2018-05-15 14:20     ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.