]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: cma: WARN if freed memory is still in use
authorMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 29 Nov 2012 03:17:32 +0000 (14:17 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2012 05:23:13 +0000 (16:23 +1100)
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 <m.szyprowski@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index dc2abffca944c7f7258b084b9ed4de04718bca90..5fc7a5d6d28e860024119748715f7cb28216fc42 100644 (file)
@@ -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