mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Rostecki <mrostecki@opensuse.org>
To: Wang Hai <wanghai38@huawei.com>,
	ast@kernel.org, daniel@iogearbox.net, kafai@fb.com,
	songliubraving@fb.com, yhs@fb.com, andrii@kernel.org,
	john.fastabend@gmail.com, kpsingh@chromium.org, toke@redhat.com,
	quentin@isovalent.com, danieltimlee@gmail.com
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf] tools: bpftool: Add missing close before bpftool net attach exit
Date: Mon, 9 Nov 2020 11:51:47 +0100	[thread overview]
Message-ID: <3b07c1a3-d5cf-dfb4-9184-00fca6c7d3b1@opensuse.org> (raw)
In-Reply-To: <20201109070410.65833-1-wanghai38@huawei.com>

On 11/9/20 8:04 AM, Wang Hai wrote:
> progfd is created by prog_parse_fd(), before 'bpftool net attach' exit,
> it should be closed.
> 
> Fixes: 04949ccc273e ("tools: bpftool: add net attach command to attach XDP on interface")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
>   tools/bpf/bpftool/net.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tools/bpf/bpftool/net.c b/tools/bpf/bpftool/net.c
> index 910e7bac6e9e..3e9b40e64fb0 100644
> --- a/tools/bpf/bpftool/net.c
> +++ b/tools/bpf/bpftool/net.c
> @@ -600,12 +600,14 @@ static int do_attach(int argc, char **argv)
>   	if (err < 0) {
>   		p_err("interface %s attach failed: %s",
>   		      attach_type_strings[attach_type], strerror(-err));
> +		close(progfd);
>   		return err;
>   	}
>   
>   	if (json_output)
>   		jsonw_null(json_wtr);
>   
> +	close(progfd);
>   	return 0;
>   }
>   

Nit - wouldn't it be better to create a `cleanup`/`out` section before 
return and use goto, to avoid copying the `close` call?

  parent reply	other threads:[~2020-11-09 10:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09  7:04 Wang Hai
2020-11-09 10:07 ` Quentin Monnet
2020-11-09 10:51 ` Michal Rostecki [this message]
2020-11-09 21:37   ` John Fastabend
2020-11-10  1:57   ` wanghai (M)

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=3b07c1a3-d5cf-dfb4-9184-00fca6c7d3b1@opensuse.org \
    --to=mrostecki@opensuse.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danieltimlee@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.com \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.com \
    --cc=wanghai38@huawei.com \
    --cc=yhs@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

all inboxes | Powered by JetHome®