[PATCH] pktgen: Fix memory leak in pktgen_if_write

Subsystems: networking [general], the rest

STALE3141d

3 messages, 3 authors, 2018-03-14 · open the first message on its own page

[PATCH] pktgen: Fix memory leak in pktgen_if_write

From: Gustavo A. R. Silva <hidden>
Date: 2018-03-14 08:07:34

_buf_ is an array and the one that must be freed is _tp_ instead.

Fixes: a870a02cc963 ("pktgen: use dynamic allocation for debug print buffer")
Reported-by: Wang Jian <redacted>
Signed-off-by: Gustavo A. R. Silva <redacted>
---
 net/core/pktgen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index fd65761..545cf08 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -913,7 +913,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			return PTR_ERR(tp);
 
 		pr_debug("%s,%zu  buffer -:%s:-\n", name, count, tp);
-		kfree(buf);
+		kfree(tp);
 	}
 
 	if (!strcmp(name, "min_pkt_size")) {
-- 
2.7.4

Re: [PATCH] pktgen: Fix memory leak in pktgen_if_write

From: Arnd Bergmann <arnd@arndb.de>
Date: 2018-03-14 08:40:39

On Wed, Mar 14, 2018 at 9:07 AM, Gustavo A. R. Silva
[off-list ref] wrote:
_buf_ is an array and the one that must be freed is _tp_ instead.

Fixes: a870a02cc963 ("pktgen: use dynamic allocation for debug print buffer")
Reported-by: Wang Jian <redacted>
Signed-off-by: Gustavo A. R. Silva <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>

Thanks for fixing up my mistake so quickly, and thanks to Wang for the report

I was about to send the same patch, but you got there first.

Re: [PATCH] pktgen: Fix memory leak in pktgen_if_write

From: David Miller <davem@davemloft.net>
Date: 2018-03-14 14:02:52

From: "Gustavo A. R. Silva" <redacted>
Date: Wed, 14 Mar 2018 03:07:27 -0500
_buf_ is an array and the one that must be freed is _tp_ instead.

Fixes: a870a02cc963 ("pktgen: use dynamic allocation for debug print buffer")
Reported-by: Wang Jian <redacted>
Signed-off-by: Gustavo A. R. Silva <redacted>
Applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help