bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 2/2] libbpf: fix legacy kprobe event creation FD error handling
Date: Mon, 20 Sep 2021 16:23:08 -0700	[thread overview]
Message-ID: <CAEf4BzZK=eMsuDcpey-tTYMVYtWZ5obuRdA-t6V4EGs_-RGf5g@mail.gmail.com> (raw)
In-Reply-To: <20210920181959.1565954-2-andrii@kernel.org>

On Mon, Sep 20, 2021 at 11:20 AM Andrii Nakryiko <andrii@kernel.org> 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@kernel.org>
> ---

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
>

      reply	other threads:[~2021-09-21  1:59 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 ` [PATCH bpf-next 2/2] libbpf: fix legacy kprobe event creation FD error handling Andrii Nakryiko
2021-09-20 23:23   ` Andrii Nakryiko [this message]

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='CAEf4BzZK=eMsuDcpey-tTYMVYtWZ5obuRdA-t6V4EGs_-RGf5g@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=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).