Re: [PATCH bpf-next v3 1/3] bpftool: fix double close in map dump

[email protected]
Newsgroups org.kernel.vger.bpf
Message-ID <559fb46f069bf2f5719e9363f2c569b5a98935ee3f10280c7991aef96cbd7ad9@mail.kernel.org>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 6b9649294ca1..e9f4dd9458cf 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -895,7 +895,6 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
>  exit_free:
>  	free(key);
>  	free(value);
> -	close(fd);
>  	free_map_kv_btf(btf);
>
>  	return err;

This isn't a bug, but since exit_free is map_dump()'s common exit and
the close ran on the success path too (and the break path also
double-closed via exit_close), would it read more accurately as something
like "map_dump() closes the map fd on all exit paths, and do_dump() closes
it again"?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31367518511
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.