Skip to content

Commit

Permalink
mm: cma: WARN if freed memory is still in use
Browse files Browse the repository at this point in the history
Memory returned to free_contig_range() must have no other references.
Let kernel to complain loudly if page reference count is not equal to 1.

[[email protected]: support sparsemem]
Signed-off-by: Marek Szyprowski <[email protected]>
Reviewed-by: Kyungmin Park <[email protected]>
Acked-by: Michal Nazarewicz <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mszyprow authored and torvalds committed Dec 21, 2012
1 parent b66c598 commit bcc2b02
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5978,8 +5978,15 @@ int alloc_contig_range(unsigned long start, unsigned long end,

void free_contig_range(unsigned long pfn, unsigned nr_pages)
{
for (; nr_pages--; ++pfn)
__free_page(pfn_to_page(pfn));
unsigned int count = 0;

for (; nr_pages--; pfn++) {
struct page *page = pfn_to_page(pfn);

count += page_count(page) != 1;
__free_page(page);
}
WARN(count != 0, "%d pages are still in use!\n", count);
}
#endif

Expand Down

0 comments on commit bcc2b02

Please sign in to comment.