From a9683532b54883a420daa180adb3a2bd347e7559 Mon Sep 17 00:00:00 2001 From: yushuailong Date: Wed, 16 Sep 2026 15:51:04 +0800 Subject: [PATCH] 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 --- 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: