Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
mm: add VM_BUG_ON_PAGE() to page_mapcount()
Browse files Browse the repository at this point in the history
Add VM_BUG_ON_PAGE() for slab pages.  _mapcount is an union with slab
struct in struct page, so we must avoid accessing _mapcount if this page
is a slab page.  Also remove the unneeded bracket.

Signed-off-by: Yalin Wang <[email protected]>
Acked-by: Kirill A. Shutemov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Wang, Yalin authored and torvalds committed Feb 12, 2015
1 parent e4b294c commit 1d148e2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ static inline void page_mapcount_reset(struct page *page)

static inline int page_mapcount(struct page *page)
{
return atomic_read(&(page)->_mapcount) + 1;
VM_BUG_ON_PAGE(PageSlab(page), page);
return atomic_read(&page->_mapcount) + 1;
}

static inline int page_count(struct page *page)
Expand Down

0 comments on commit 1d148e2

Please sign in to comment.