From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>
Subject: [PATCH bpf-next 2/2] libbpf: fix legacy kprobe event creation FD error handling
Date: Mon, 20 Sep 2021 11:19:59 -0700 [thread overview]
Message-ID: <20210920181959.1565954-2-andrii@kernel.org> (raw)
In-Reply-To: <20210920181959.1565954-1-andrii@kernel.org>
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@kernel.org>
---
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
next prev parent reply other threads:[~2021-09-20 18:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 18:19 [PATCH bpf-next 1/2] libbpf: fix memory leak in legacy kprobe attach logic Andrii Nakryiko
2021-09-20 18:19 ` Andrii Nakryiko [this message]
2021-09-20 23:23 ` [PATCH bpf-next 2/2] libbpf: fix legacy kprobe event creation FD error handling Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210920181959.1565954-2-andrii@kernel.org \
--to=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).