mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 8/8 V2] staging: dgap: fix memory leak in dgap_parsefile()
@ 2014-07-15  9:19 Daeseok Youn
  0 siblings, 0 replies; only message in thread
From: Daeseok Youn @ 2014-07-15  9:19 UTC (permalink / raw)
  To: lidza.louina, markh
  Cc: markh, daeseok.youn, gregkh, driverdev-devel, devel, linux-kernel

The p->u.board.status is allocated and set a string as
"No" once within allocating a node of BNODE type.
But it also set again with kstrdup() in case of "STATUS"
or "ID". So just free this buffer and allocate again with
kstrdup().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
---
V2: just use kfree for buffers which assigned to newly value
    and then allocate again properly.

 drivers/staging/dgap/dgap.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index e4ea68b..76503fe 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -6599,6 +6599,8 @@ static int dgap_parsefile(char **in)
 				pr_err("parse: unexpected end of file\n");
 				return -1;
 			}
+
+			kfree(p->u.board.status);
 			p->u.board.status = kstrdup(s, GFP_KERNEL);
 			break;
 
@@ -6649,6 +6651,7 @@ static int dgap_parsefile(char **in)
 				return -1;
 			}
 
+			kfree(p->u.board.status);
 			p->u.board.status = kstrdup(s, GFP_KERNEL);
 
 			if (p->type == CNODE) {
-- 
1.7.1


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

only message in thread, other threads:[~2014-07-15  9:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15  9:19 [PATCH 8/8 V2] staging: dgap: fix memory leak in dgap_parsefile() Daeseok Youn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®