mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "wanghai (M)" <wanghai38@huawei.com>
To: Michal Rostecki <mrostecki@opensuse.org>
Cc: <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>, <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: Tue, 10 Nov 2020 09:57:20 +0800	[thread overview]
Message-ID: <e43d28b0-f4eb-641c-2130-ea12e37b6b07@huawei.com> (raw)
In-Reply-To: <3b07c1a3-d5cf-dfb4-9184-00fca6c7d3b1@opensuse.org>


在 2020/11/9 18:51, Michal Rostecki 写道:
> 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?
> .
>
Thanks for review. I just sent v2 patch

"[PATCH v2 bpf] tools: bpftool: Add missing close before bpftool net 
attach exit"


      parent reply	other threads:[~2020-11-10  1:57 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
2020-11-10  1:57   ` wanghai (M) [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=e43d28b0-f4eb-641c-2130-ea12e37b6b07@huawei.com \
    --to=wanghai38@huawei.com \
    --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=mrostecki@opensuse.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.com \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.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®