Skip to content

Commit

Permalink
[PATCH] mm: remove_mapping() safeness
Browse files Browse the repository at this point in the history
Some users of remove_mapping had been unsafe.

Modify the remove_mapping precondition to ensure the caller has locked the
page and obtained the correct mapping.  Modify callers to ensure the
mapping is the correct one.

[hugh@veritas.com: swapper_space fix]
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Sep 26, 2006
1 parent bfa5bf6 commit 28e4d96
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ static pageout_t pageout(struct page *page, struct address_space *mapping)

int remove_mapping(struct address_space *mapping, struct page *page)
{
if (!mapping)
return 0; /* truncate got there first */
BUG_ON(!PageLocked(page));
BUG_ON(mapping != page_mapping(page));

write_lock_irq(&mapping->tree_lock);

Expand Down Expand Up @@ -547,7 +547,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
goto free_it;
}

if (!remove_mapping(mapping, page))
if (!mapping || !remove_mapping(mapping, page))
goto keep_locked;

free_it:
Expand Down

0 comments on commit 28e4d96

Please sign in to comment.