On Mon, Sep 20, 2021 at 11:20 AM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote: > > open() returns -1 on error, not zero FD. Fix the error handling logic. > Reported by Coverity statis analysis. > > Fixes: ca304b40c20d ("libbpf: Introduce legacy kprobe events support") > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > --- This patch is superseded by a new patch series ([0]), please don't apply. [0] https://patchwork.kernel.org/project/netdevbpf/list/?series=550083&state=* > tools/lib/bpf/libbpf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 6d2f12db6034..761497be6ffc 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -9036,7 +9036,7 @@ static int poke_kprobe_events(bool add, const char *name, bool retprobe, uint64_ > } > > fd = open(file, O_WRONLY | O_APPEND, 0); > - if (!fd) > + if (fd < 0) > return -errno; > ret = write(fd, cmd, strlen(cmd)); > if (ret < 0) > -- > 2.30.2 >