mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Michal Rostecki <mrostecki@opensuse.org>,
	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, 09 Nov 2020 13:37:50 -0800	[thread overview]
Message-ID: <5fa9b6ae893bf_8c0e20825@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <3b07c1a3-d5cf-dfb4-9184-00fca6c7d3b1@opensuse.org>

Michal Rostecki wrote:
> 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?

I agree would be nicer.

  reply	other threads:[~2020-11-09 21:38 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
2020-11-09 21:37   ` John Fastabend [this message]
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=5fa9b6ae893bf_8c0e20825@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danieltimlee@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrostecki@opensuse.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®