aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Jackson <pj@sgi.com>2005-09-28 09:42:24 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-28 10:58:51 -0400
commit5134fc15b643dc36eb9aa77e4318b886844a9ac5 (patch)
tree170339651303da0bb530c407300f09d3cd39caa2
parent2dd3c1df95fb29e9227f16ccd7d786d129e2b34d (diff)
[PATCH] cpuset read past eof memory leak fix
Don't leak a page of memory if user reads a cpuset file past eof. Signed-off-by: KUROSAWA Takahiro <kurosawa@valinux.co.jp> Signed-off-by: Paul Jackson <pj@sgi.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--kernel/cpuset.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 79866bc6b3a1..6a6e87b2f2fd 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -969,7 +969,7 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
969 ssize_t retval = 0; 969 ssize_t retval = 0;
970 char *s; 970 char *s;
971 char *start; 971 char *start;
972 size_t n; 972 ssize_t n;
973 973
974 if (!(page = (char *)__get_free_page(GFP_KERNEL))) 974 if (!(page = (char *)__get_free_page(GFP_KERNEL)))
975 return -ENOMEM; 975 return -ENOMEM;
@@ -999,12 +999,13 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
999 *s++ = '\n'; 999 *s++ = '\n';
1000 *s = '\0'; 1000 *s = '\0';
1001 1001
1002 /* Do nothing if *ppos is at the eof or beyond the eof. */
1003 if (s - page <= *ppos)
1004 return 0;
1005
1006 start = page + *ppos; 1002 start = page + *ppos;
1007 n = s - start; 1003 n = s - start;
1004
1005 /* Do nothing if *ppos is at the eof or beyond the eof. */
1006 if (n <= 0)
1007 goto out;
1008
1008 retval = n - copy_to_user(buf, start, min(n, nbytes)); 1009 retval = n - copy_to_user(buf, start, min(n, nbytes));
1009 *ppos += retval; 1010 *ppos += retval;
1010out: 1011out: