netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix memory leak in net/ipv4/tcp_probe.c::tcpprobe_read()
@ 2006-07-30 19:38 Jesper Juhl
  2006-07-30 21:29 ` Stephen Hemminger
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Juhl @ 2006-07-30 19:38 UTC (permalink / raw)
  To: linux-kernel, Stephen Hemminger, David S. Miller,
	Alexey Kuznetsov, James Morris, Hideaki YOSHIFUJI, Pekka Savola,
	Patrick McHardy, netdev

There's an obvious memory leak in net/ipv4/tcp_probe.c::tcpprobe_read()
We are not freeing 'tbuf' on error.
Patch below fixes that.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 net/ipv4/tcp_probe.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

--- linux-2.6.18-rc3-orig/net/ipv4/tcp_probe.c	2006-07-30 13:21:53.000000000 +0200
+++ linux-2.6.18-rc3/net/ipv4/tcp_probe.c	2006-07-30 21:32:04.000000000 +0200
@@ -129,8 +129,10 @@ static ssize_t tcpprobe_read(struct file
 
 	error = wait_event_interruptible(tcpw.wait,
 					 __kfifo_len(tcpw.fifo) != 0);
-	if (error)
+	if (error) {
+		vfree(tbuf);
 		return error;
+	}
 
 	cnt = kfifo_get(tcpw.fifo, tbuf, len);
 	error = copy_to_user(buf, tbuf, cnt);




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-08-10 23:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-30 19:38 [PATCH] fix memory leak in net/ipv4/tcp_probe.c::tcpprobe_read() Jesper Juhl
2006-07-30 21:29 ` Stephen Hemminger
2006-07-30 21:48   ` James Morris
2006-07-30 21:51     ` Jesper Juhl
2006-07-30 22:56       ` David Miller
2006-08-04 23:30         ` Jesper Juhl
2006-08-04 23:59           ` David Miller
2006-08-10 22:18             ` Jesper Juhl
2006-08-10 23:36               ` David Miller
2006-08-10 23:52                 ` Stephen Hemminger
2006-08-10 23:54                   ` David Miller

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).