Commit 28e4d965 authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds
Browse files

[PATCH] mm: remove_mapping() safeness

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.

[ swapper_space fix]
Signed-off-by: default avatarNick Piggin <>
Signed-off-by: default avatarHugh Dickins <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent bfa5bf6d
......@@ -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(mapping != page_mapping(page));
......@@ -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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment