Dave, here is my version...
Don't leak memory on interrupted read. And only allocate
as much memory as needed.
Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
--- linux-2.6.orig/net/ipv4/tcp_probe.c 2006-08-10 16:32:36.000000000 -0700
+++ linux-2.6/net/ipv4/tcp_probe.c 2006-08-10 16:45:30.000000000 -0700
@@ -114,7 +114,7 @@
static ssize_t tcpprobe_read(struct file *file, char __user *buf,
size_t len, loff_t *ppos)
{
- int error = 0, cnt = 0;
+ int error, cnt;
unsigned char *tbuf;
if (!buf || len < 0)
@@ -123,15 +123,16 @@
if (len == 0)
return 0;
- tbuf = vmalloc(len);
- if (!tbuf)
- return -ENOMEM;
-
error = wait_event_interruptible(tcpw.wait,
__kfifo_len(tcpw.fifo) != 0);
if (error)
return error;
+ len = min(len, kfifo_len(tcpw.fifo));
+ tbuf = vmalloc(len);
+ if (!tbuf)
+ return -ENOMEM;
+
cnt = kfifo_get(tcpw.fifo, tbuf, len);
error = copy_to_user(buf, tbuf, cnt);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html