archive mirror
 help / color / mirror / Atom feed
* [PATCH] kdb: fix possible memory leak in kdb_defcmd2()
@ 2012-09-02 13:29 Wei Yongjun
  0 siblings, 0 replies; only message in thread
From: Wei Yongjun @ 2012-09-02 13:29 UTC (permalink / raw)
  To: jason.wessel; +Cc: yongjun_wei, kgdb-bugreport, linux-kernel

From: Wei Yongjun <>

In the error handling case of kdb_defcmd2() s->command has
been set to NULL but the save_command remain no free, this will
cause memory leak.

spatch with a semantic match is used to found this problem.

Signed-off-by: Wei Yongjun <>
 kernel/debug/kdb/kdb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 31df170..0cbe79f 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -651,6 +651,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)
 		kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
 		s->usable = 0;
+		kfree(save_command);
 		return KDB_NOTIMP;
 	memcpy(s->command, save_command, s->count * sizeof(*(s->command)));

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-09-02 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-02 13:29 [PATCH] kdb: fix possible memory leak in kdb_defcmd2() Wei Yongjun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).