skel_fd is passed to create_dwfl, which calls dup() on skel_fd. create_dwfl handles closing the dup'ed fd but not the original.
Ensure the original skel_fd is closed after it's passed to create_dwfl. Signed-off-by: Aaron Merey <ame...@redhat.com> --- src/readelf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/readelf.c b/src/readelf.c index 3e97b64c..6526db07 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -11921,7 +11921,13 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr) fprintf (stderr, "Warning: Couldn't open DWARF skeleton file" " '%s'\n", skel_name); else - skel_dwfl = create_dwfl (skel_fd, skel_name); + { + skel_dwfl = create_dwfl (skel_fd, skel_name); + + /* skel_fd was dup'ed by create_dwfl. We can close the + original now. */ + close (skel_fd); + } if (skel_dwfl != NULL) { -- 2.47.1