Add free() call when handling some error returns.

Signed-off-by: Youling Tang <tangyoul...@loongson.cn>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to