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> --- 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