This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a9683532b54883a420daa180adb3a2bd347e7559
Author: yushuailong <[email protected]>
AuthorDate: Wed Sep 16 15:51:04 2026 +0800

    libc/elf: Free the registry entry when removing a module.
    
    libelf_remove() takes the module out of the registry but never frees
    the registry entry, so every successful rmmod()/dlclose() leaks
    sizeof(struct module_s), the name included.  The lib_free() call was
    dropped by e9550783d3 when the removal path was reworked.
    
    Free the entry after the registry lock is released.
    
    Assisted-by: OpenAI Codex
    Signed-off-by: yushuailong <[email protected]>
---
 libs/libc/elf/elf_remove.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libs/libc/elf/elf_remove.c b/libs/libc/elf/elf_remove.c
index 67722937b33..fd004f0584e 100644
--- a/libs/libc/elf/elf_remove.c
+++ b/libs/libc/elf/elf_remove.c
@@ -240,6 +240,8 @@ int libelf_remove(FAR void *handle)
 
   /* And free the registry entry */
 
+  lib_free(modp);
+
   return ret;
 
 errout_with_lock:

Reply via email to