diff options
| author | Yuan Chen <chenyuan@kylinos.cn> | 2026-08-10 22:22:22 +0800 |
|---|---|---|
| committer | Andrii Nakryiko <andrii@kernel.org> | 2026-08-13 14:54:06 -0700 |
| commit | 259d60f5bfa41056fe01cbf2ba3f6f0331865a16 (patch) | |
| tree | 7db0d1fb16144cb126ac2dc1a3eb9b095ea86e31 /tools/perf/scripts/python/bin | |
| parent | aacd13e1eb68f2c9049fc0cf7aed89694c3e0713 (diff) | |
bpftool: Fix double close in map dump
map_dump() closes the map fd in its error path, and do_dump() then
closes the same fd again after a successful dump. Closing an already
closed fd leaves errno set to EBADF, which poisons later errno checks
such as the batch file read check in do_batch(). Let do_dump() own the
fd and remove the close from map_dump().
The same double-close pattern exists in do_show_subset(): both
show_map_close_json() and show_map_close_plain() already close the fd,
so drop the extra close() there as well.
Also propagate the error when bpf_map_get_info_by_fd() fails on a
subsequent map in do_dump(): set err = -1 before breaking out of the
loop, so a later failure is not silently hidden after an earlier
iteration succeeded.
Fixes: 99f9863a0c45f ("bpftool: Match maps by name")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260810142224.2907373-2-chenyuan_fl@163.com
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
