Skip to contentSkip to conversation

fix missing unlock_page in mm/rmap.c

PATCH In review Nick Piggin 2 participants 2 messages Sep 18, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix missing unlock_page in mm/rmap.c

Please apply.

A required unlock_page will be missed in a very rare (but possible) race condition. Acked by Hugh, who says:

It'll be hard to hit because of the additional page_mapped test above, with truncate unmapping ptes from mms before it advances to removing pages from cache; but nothing to prevent it happening.

---

 linux-2.6-npiggin/mm/rmap.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
mm/rmap.c renamed from mm/rmap.c~mm-rmap-missing-unlock +3 -2
diff -puN mm/rmap.c~mm-rmap-missing-unlock mm/rmap.c
@@ -406,8 +406,9 @@ int page_referenced(struct page *page, i
 			referenced += page_referenced_file(page);
 		else if (TestSetPageLocked(page))
 			referenced++;
-		else if (page->mapping) {
-			referenced += page_referenced_file(page);
+		else {
+			if (page->mapping)
+				referenced += page_referenced_file(page);
 			unlock_page(page);
 		}
 	}

_

#1 lore raw
Quoted 8 lines · Nick Piggin

Please apply.
A required unlock_page will be missed in a very rare (but possible) race condition. Acked by Hugh, who says:
It'll be hard to hit because of the additional page_mapped test above, with truncate unmapping ptes from mms before it advances to removing pages from cache; but nothing to prevent it happening.

I've hit a missing unlock_page(). I'll see if this fixed it.

-- wli