Messages in this thread Patch in this message | | | Date | Wed, 28 Sep 2005 18:25:58 +0900 | From | KUROSAWA Takahiro <> | Subject | [PATCH][BUG] fix memory leak on reading cpuset files after seeking beyond eof |
| |
On Tue, 27 Sep 2005 20:39:02 +0900 KUROSAWA Takahiro <kurosawa@valinux.co.jp> wrote:
> On Tue, 27 Sep 2005 01:37:51 -0700 > Paul Jackson <pj@sgi.com> wrote: > > > The above reminds me of a bug fix that you provided in the previous > > patch set, for the case *ppos >= eof. I wonder if we have duplicated > > code here. > Ah, yes, we need to fix the bug in the cpuset code introduced by me...
I fixed the bug. Sorry for my previous incomplete patch. The following patch is against linux-2.6.14-rc2.
Signed-off-by: KUROSAWA Takahiro <kurosawa@valinux.co.jp>
--- from-0001/kernel/cpuset.c +++ to-work/kernel/cpuset.c 2005-09-28 17:42:00.759401736 +0900 @@ -969,7 +969,7 @@ static ssize_t cpuset_common_file_read(s ssize_t retval = 0; char *s; char *start; - size_t n; + ssize_t n; if (!(page = (char *)__get_free_page(GFP_KERNEL))) return -ENOMEM; @@ -999,12 +999,13 @@ static ssize_t cpuset_common_file_read(s *s++ = '\n'; *s = '\0'; - /* Do nothing if *ppos is at the eof or beyond the eof. */ - if (s - page <= *ppos) - return 0; - start = page + *ppos; n = s - start; + + /* Do nothing if *ppos is at the eof or beyond the eof. */ + if (n <= 0) + goto out; + retval = n - copy_to_user(buf, start, min(n, nbytes)); *ppos += retval; out: - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |