All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Tobias Klauser <tklauser@distanz.ch>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf] tools, bpftool: Fix memory leak in codegen error cases
Date: Wed, 10 Jun 2020 11:31:03 -0700	[thread overview]
Message-ID: <CAEf4BzaGRcgj5COyfsNtR6uGgakCCBT=Q3osPR84ap2r1EMRjg@mail.gmail.com> (raw)
In-Reply-To: <20200610130804.21423-1-tklauser@distanz.ch>

On Wed, Jun 10, 2020 at 6:10 AM Tobias Klauser <tklauser@distanz.ch> wrote:
>
> Free the memory allocated for the template on error paths in function
> codegen.
>
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  tools/bpf/bpftool/gen.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index a3c4bb86c05a..ecbae47e66b8 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
> @@ -224,6 +224,7 @@ static int codegen(const char *template, ...)
>                 } else {
>                         p_err("unrecognized character at pos %td in template '%s'",
>                               src - template - 1, template);
> +                       free(s);
>                         return -EINVAL;
>                 }
>         }
> @@ -234,6 +235,7 @@ static int codegen(const char *template, ...)
>                         if (*src != '\t') {
>                                 p_err("not enough tabs at pos %td in template '%s'",
>                                       src - template - 1, template);
> +                               free(s);
>                                 return -EINVAL;
>                         }
>                 }
> --
> 2.27.0
>

  reply	other threads:[~2020-06-10 18:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 13:08 [PATCH bpf] tools, bpftool: Fix memory leak in codegen error cases Tobias Klauser
2020-06-10 18:31 ` Andrii Nakryiko [this message]
2020-06-11 14:24 ` Daniel Borkmann

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='CAEf4BzaGRcgj5COyfsNtR6uGgakCCBT=Q3osPR84ap2r1EMRjg@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=tklauser@distanz.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.