kdb: fix memory leak in kdb_main.c
authorJovi Zhang <bookjovi@gmail.com>
Wed, 10 Nov 2010 13:22:18 +0000 (07:22 -0600)
committerJason Wessel <jason.wessel@windriver.com>
Wed, 17 Nov 2010 19:54:57 +0000 (13:54 -0600)
Call kfree in the error path as well as the success path in kdb_ll().

Signed-off-by: Jovi Zhang <bookjovi@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
kernel/debug/kdb/kdb_main.c

index 37755d621924e5256b3494d5e94b57415be5a3f1..3ab3feee784048fa08e93ae25ccc755cb8d33d96 100644 (file)
@@ -2361,7 +2361,7 @@ static int kdb_pid(int argc, const char **argv)
  */
 static int kdb_ll(int argc, const char **argv)
 {
-       int diag;
+       int diag = 0;
        unsigned long addr;
        long offset = 0;
        unsigned long va;
@@ -2400,20 +2400,21 @@ static int kdb_ll(int argc, const char **argv)
                char buf[80];
 
                if (KDB_FLAG(CMD_INTERRUPT))
-                       return 0;
+                       goto out;
 
                sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
                diag = kdb_parse(buf);
                if (diag)
-                       return diag;
+                       goto out;
 
                addr = va + linkoffset;
                if (kdb_getword(&va, addr, sizeof(va)))
-                       return 0;
+                       goto out;
        }
-       kfree(command);
 
-       return 0;
+out:
+       kfree(command);
+       return diag;
 }
 
 static int kdb_kgdb(int argc, const char **argv)