The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=70fb92cd56bfe88a12d2a253542320bad7198321

commit 70fb92cd56bfe88a12d2a253542320bad7198321
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-06-29 20:08:31 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-06-29 20:33:12 +0000

    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
---
 libexec/rtld-elf/map_object.c | 10 ++++------
 1 file 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

Reply via email to