+ fix-memory-leak-in-net-ipv4-tcp_probectcpprobe_read.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     fix memory leak in net/ipv4/tcp_probe.c::tcpprobe_read()

has been added to the -mm tree.  Its filename is

     fix-memory-leak-in-net-ipv4-tcp_probectcpprobe_read.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: fix memory leak in net/ipv4/tcp_probe.c::tcpprobe_read()
From: Jesper Juhl <jesper.juhl@xxxxxxxxx>

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

[akpm@xxxxxxxx: reworked to avoid return-from-middle-of-function]
Signed-off-by: Jesper Juhl <jesper.juhl@xxxxxxxxx>
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 net/ipv4/tcp_probe.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff -puN net/ipv4/tcp_probe.c~fix-memory-leak-in-net-ipv4-tcp_probectcpprobe_read net/ipv4/tcp_probe.c
--- a/net/ipv4/tcp_probe.c~fix-memory-leak-in-net-ipv4-tcp_probectcpprobe_read
+++ a/net/ipv4/tcp_probe.c
@@ -114,7 +114,8 @@ static int tcpprobe_open(struct inode * 
 static ssize_t tcpprobe_read(struct file *file, char __user *buf,
 			     size_t len, loff_t *ppos)
 {
-	int error = 0, cnt;
+	int error;
+	int cnt = 0;
 	unsigned char *tbuf;
 
 	if (!buf || len < 0)
@@ -129,12 +130,10 @@ static ssize_t tcpprobe_read(struct file
 
 	error = wait_event_interruptible(tcpw.wait,
 					 __kfifo_len(tcpw.fifo) != 0);
-	if (error)
-		return error;
-
-	cnt = kfifo_get(tcpw.fifo, tbuf, len);
-	error = copy_to_user(buf, tbuf, cnt);
-
+	if (error == 0) {
+		cnt = kfifo_get(tcpw.fifo, tbuf, len);
+		error = copy_to_user(buf, tbuf, cnt);
+	}
 	vfree(tbuf);
 
 	return error ? error : cnt;
_

Patches currently in -mm which might be from jesper.juhl@xxxxxxxxx are

git-block.patch
fix-memory-leak-in-net-ipv4-tcp_probectcpprobe_read.patch
debug-shared-irqs.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux