[PATCH] scripts: prevent resource leak

From: Minhong He
Date: Fri Nov 22 2024 - 04:29:32 EST


In the main() function, the fopen() is used to open the file.
When the file is successfully opened, not using fclose() to close the file.
It will cause memory leak or file corruption.

Signed-off-by: Minhong He <heminhong@xxxxxxxxxx>
---
scripts/insert-sys-cert.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836c2342..dcd1902b495e 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -361,6 +361,7 @@ int main(int argc, char **argv)
get_symbol_from_map(hdr, system_map, USED_SYM, &used_sym);
get_symbol_from_map(hdr, system_map, LSIZE_SYM, &lsize_sym);
cert_sym.size = used_sym.address - cert_sym.address;
+ fclose(system_map);
} else {
info("Symbol table found.\n");
if (system_map_file)
--
2.25.1