mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
tools, bpftool: Add missing close before bpftool net attach exit
progfd is created by prog_parse_fd() in do_attach() and before the latter
returns in case of success, the file descriptor should be closed.
Fixes: 04949ccc27
("tools: bpftool: add net attach command to attach XDP on interface")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20201113115152.53178-1-wanghai38@huawei.com
This commit is contained in:
parent
9602182810
commit
50431b4568
1 changed files with 9 additions and 9 deletions
|
@ -578,8 +578,8 @@ static int do_attach(int argc, char **argv)
|
||||||
|
|
||||||
ifindex = net_parse_dev(&argc, &argv);
|
ifindex = net_parse_dev(&argc, &argv);
|
||||||
if (ifindex < 1) {
|
if (ifindex < 1) {
|
||||||
close(progfd);
|
err = -EINVAL;
|
||||||
return -EINVAL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc) {
|
if (argc) {
|
||||||
|
@ -587,8 +587,8 @@ static int do_attach(int argc, char **argv)
|
||||||
overwrite = true;
|
overwrite = true;
|
||||||
} else {
|
} else {
|
||||||
p_err("expected 'overwrite', got: '%s'?", *argv);
|
p_err("expected 'overwrite', got: '%s'?", *argv);
|
||||||
close(progfd);
|
err = -EINVAL;
|
||||||
return -EINVAL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,17 +596,17 @@ static int do_attach(int argc, char **argv)
|
||||||
if (is_prefix("xdp", attach_type_strings[attach_type]))
|
if (is_prefix("xdp", attach_type_strings[attach_type]))
|
||||||
err = do_attach_detach_xdp(progfd, attach_type, ifindex,
|
err = do_attach_detach_xdp(progfd, attach_type, ifindex,
|
||||||
overwrite);
|
overwrite);
|
||||||
|
if (err) {
|
||||||
if (err < 0) {
|
|
||||||
p_err("interface %s attach failed: %s",
|
p_err("interface %s attach failed: %s",
|
||||||
attach_type_strings[attach_type], strerror(-err));
|
attach_type_strings[attach_type], strerror(-err));
|
||||||
return err;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_output)
|
if (json_output)
|
||||||
jsonw_null(json_wtr);
|
jsonw_null(json_wtr);
|
||||||
|
cleanup:
|
||||||
return 0;
|
close(progfd);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_detach(int argc, char **argv)
|
static int do_detach(int argc, char **argv)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue