From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: Re: [PATCH bpf] tools: bpf: fix NULL return handling in bpf__prepare_load Date: Tue, 15 May 2018 11:11:43 -0300 Message-ID: <20180515141143.GH2917@kernel.org> References: <20180511112142.23324-1-yuehaibing@huawei.com> <605c7b96-83dc-9a9e-7037-32b2c2dfcb2e@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: YueHaibing , alexander.shishkin@linux.intel.com, mingo@redhat.com, peterz@infradead.org, netdev@vger.kernel.org, namhyung@kernel.org To: Daniel Borkmann Return-path: Received: from mail.kernel.org ([198.145.29.99]:47178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbeEOOLr (ORCPT ); Tue, 15 May 2018 10:11:47 -0400 Content-Disposition: inline In-Reply-To: <605c7b96-83dc-9a9e-7037-32b2c2dfcb2e@iogearbox.net> Sender: netdev-owner@vger.kernel.org List-ID: Em Sun, May 13, 2018 at 01:20:22AM +0200, Daniel Borkmann escreveu: > [ +Arnaldo ] > > On 05/11/2018 01:21 PM, YueHaibing wrote: > > 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 > > --- > > tools/perf/util/bpf-loader.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > This should probably be routed via Arnaldo due to the fix in perf itself. If > there's no particular preference on which tree, we could potentially route it > as well via bpf with Acked-by from Arnaldo, but that is up to him. Arnaldo, > any preference? I'm preparing a pull req right now, and working a bit on perf's BPF support, so why not, I'll merge it, thanks, - Arnaldo > > 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; > > } > >