aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2026-06-29 20:08:31 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2026-06-29 20:33:12 +0000
commit70fb92cd56bfe88a12d2a253542320bad7198321 (patch)
tree41f3b179f2bf9c6bb7eee43729a4775797c2c080
parent1e370f038778e16c4b31f8992dda339d429e5cb8 (diff)
rtld: unify the return path for map_object()
Reviewed by: kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57908
-rw-r--r--libexec/rtld-elf/map_object.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index d769d01d3b24..0b4e847f407e 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -338,7 +338,8 @@ map_object(int fd, const char *path, const struct stat *sb, bool ismain)
obj->stack_flags = stack_flags;
if (note_start < note_end)
digest_notes(obj, note_start, note_end);
- if (note_map != NULL)
+finish:
+ if (note_map != NULL && note_map != MAP_FAILED)
munmap(note_map, note_map_len);
munmap(hdr, page_size);
free(segs);
@@ -347,13 +348,10 @@ map_object(int fd, const char *path, const struct stat *sb, bool ismain)
error1:
munmap(mapbase, mapsize);
error:
- if (note_map != NULL && note_map != MAP_FAILED)
- munmap(note_map, note_map_len);
if (!phdr_in_zero_page(hdr))
munmap(phdr, hdr->e_phnum * sizeof(phdr[0]));
- munmap(hdr, page_size);
- free(segs);
- return (NULL);
+ obj = NULL;
+ goto finish;
}
bool