From: Marek Szyprowski Date: Thu, 29 Nov 2012 03:17:32 +0000 (+1100) Subject: mm: cma: WARN if freed memory is still in use X-Git-Tag: next-20121205~1^2~282 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b4f615e971b155f5841b2697ff28ea7f204828b7;p=karo-tx-linux.git mm: cma: WARN if freed memory is still in use 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. Signed-off-by: Marek Szyprowski Reviewed-by: Kyungmin Park Acked-by: Michal Nazarewicz Signed-off-by: Andrew Morton --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index dc2abffca944..5fc7a5d6d28e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5944,8 +5944,13 @@ done: void free_contig_range(unsigned long pfn, unsigned nr_pages) { - for (; nr_pages--; ++pfn) - __free_page(pfn_to_page(pfn)); + struct page *page = pfn_to_page(pfn); + int count = 0; + for (; nr_pages--; page++) { + count += page_count(page) != 1; + __free_page(page); + } + WARN(count != 0, "%d pages are still in use!\n", count); } #endif