* Re: [PATCH] nfs client O_DIRECT oops
[not found] <42236AC6.6000609@RedHat.com>
@ 2005-03-01 1:00 ` Pete Zaitcev
2005-03-01 1:17 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2005-03-01 1:00 UTC (permalink / raw)
To: brugolsky; +Cc: zaitcev, SteveD, linux-kernel, torvalds
On Mon, 28 Feb 2005 14:02:30 -0500, Steve Dickson <SteveD@redhat.com> wrote:
> Discovered using AKPM's ext3-tools: odwrite -ko 0 16385 foo
> Signed-off-by: Bill Rugolsky <brugolsky@telemetry-investments.com>
> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The root cause of the bug is that the code violates the principle of the
least surprise, which in this case is: if a function fails, you do not have
to clean up for that function. Therefore, Bill's fix papers over instead
of fixing.
This is how I think it should have been fixed:
--- linux-2.6.9-5.EL/fs/nfs/direct.c 2004-10-18 14:55:07.000000000 -0700
+++ linux-2.6.9-5.EL-nfs/fs/nfs/direct.c 2005-02-28 16:48:54.000000000 -0800
@@ -86,6 +86,8 @@
page_count, (rw == READ), 0,
*pages, NULL);
up_read(¤t->mm->mmap_sem);
+ if (result < 0)
+ kfree(*pages);
}
return result;
}
@@ -211,7 +213,6 @@
page_count = nfs_get_user_pages(READ, user_addr, size, &pages);
if (page_count < 0) {
- nfs_free_user_pages(pages, 0, 0);
if (tot_bytes > 0)
break;
return page_count;
@@ -377,7 +378,6 @@
page_count = nfs_get_user_pages(WRITE, user_addr, size, &pages);
if (page_count < 0) {
- nfs_free_user_pages(pages, 0, 0);
if (tot_bytes > 0)
break;
return page_count;
Best wishes,
-- Pete
^ permalink raw reply [flat|nested] 2+ messages in thread