diff mbox series

pktgen: Fix memory leak in pktgen_if_write

Message ID 20180314080727.GA17319@embeddedgus
State Accepted, archived
Delegated to: David Miller
Headers show
Series pktgen: Fix memory leak in pktgen_if_write | expand

Commit Message

Gustavo A. R. Silva March 14, 2018, 8:07 a.m. UTC
_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 <jianjian.wang1@gmail.com>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/core/pktgen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arnd Bergmann March 14, 2018, 8:40 a.m. UTC | #1
On Wed, Mar 14, 2018 at 9:07 AM, Gustavo A. R. Silva
<gustavo@embeddedor.com> 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 <jianjian.wang1@gmail.com>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

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.
David Miller March 14, 2018, 2:02 p.m. UTC | #2
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
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 <jianjian.wang1@gmail.com>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied, thanks.
diff mbox series

Patch

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")) {