mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* 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(&current->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

* Re: [PATCH] nfs client O_DIRECT oops
  2005-03-01  1:00 ` [PATCH] nfs client O_DIRECT oops Pete Zaitcev
@ 2005-03-01  1:17   ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2005-03-01  1:17 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: brugolsky, SteveD, linux-kernel



On Mon, 28 Feb 2005, Pete Zaitcev wrote:
> 
> This is how I think it should have been fixed:

Since this seems a cleanup, I'll drop it for now. Can you re-send after 
2.6.11 (or forward it to the nfs people) so that it gets cleaned up at 
some point? I do agree that your patch seems to be cleaner.

		Linus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-01  1:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <42236AC6.6000609@RedHat.com>
2005-03-01  1:00 ` [PATCH] nfs client O_DIRECT oops Pete Zaitcev
2005-03-01  1:17   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®