Message ID | 20201109070410.65833-1-wanghai38@huawei.com |
---|---|
State | Not Applicable |
Delegated to: | BPF Maintainers |
Headers | show |
Series | [bpf] tools: bpftool: Add missing close before bpftool net attach exit | expand |
Context | Check | Description |
---|---|---|
jkicinski/cover_letter | success | Link |
jkicinski/fixes_present | success | Link |
jkicinski/patch_count | success | Link |
jkicinski/tree_selection | success | Clearly marked for bpf |
jkicinski/subject_prefix | success | Link |
jkicinski/source_inline | success | Was 0 now: 0 |
jkicinski/verify_signedoff | success | Link |
jkicinski/module_param | success | Was 0 now: 0 |
jkicinski/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
jkicinski/kdoc | success | Errors and warnings before: 0 this patch: 0 |
jkicinski/verify_fixes | success | Link |
jkicinski/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 14 lines checked |
jkicinski/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
jkicinski/header_inline | success | Link |
jkicinski/stable | success | Stable not CCed |
On 09/11/2020 07:04, 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> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Thanks! Quentin
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?
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.
在 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"
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; }
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(+)