diff mbox series

tools: Fix potential memory leak in aisimage.c

Message ID 20250418174939.180817-1-ant.v.moryakov@gmail.com
State New
Delegated to: Tom Rini
Headers show
Series tools: Fix potential memory leak in aisimage.c | expand

Commit Message

Anton Moryakov April 18, 2025, 5:49 p.m. UTC
From: Maks Mishin <maks.mishinFZ@gmail.com>

The 'line' variable is dynamically allocated by getline() function
during config file parsing but wasn't being freed before function
exit, causing memory leak. This was detected by static analysis.

Add missing free() call before closing the file descriptor to
prevent memory leak.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
---
 tools/aisimage.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/tools/aisimage.c b/tools/aisimage.c
index b8b3ee32..6091c8d5 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -346,6 +346,7 @@  static int aisimage_generate(struct image_tool_params *params,
 		}
 
 	}
+	free(line);
 	fclose(fd);
 
 	aishdr = ais_copy_image(params, aishdr);