Skip to contentSkip to conversation

nfs client O_DIRECT oops

PATCH Pete Zaitcev 2 participants 2 messages Mar 1, 2005 1 message not in the archive NFS client

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · Steve Dickson

Discovered using AKPM's ext3-tools: odwrite -ko 0 16385 foo

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:

fs/nfs/direct.c +2 -2
@@ -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

#2 lore raw
Quoted 2 lines · Pete Zaitcev

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