[PATCH] kexec-tools: Fix resource leaks in kexec.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add free() call when handling some error returns.

Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxxx>
---
 kexec/kexec.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index a62b362..a0f0908 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -1128,11 +1128,15 @@ char *get_command_line(void)
 		die("Could not allocate memory to read /proc/cmdline.");
 
 	fp = fopen("/proc/cmdline", "r");
-	if (!fp)
+	if (!fp) {
+		free(line);
 		die("Could not open /proc/cmdline.");
+	}
 
-	if (fgets(line, sizeof_line, fp) == NULL)
+	if (fgets(line, sizeof_line, fp) == NULL) {
+		free(line);
 		die("Can't read /proc/cmdline.");
+	}
 
 	fclose(fp);
 
-- 
2.1.0


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux