dmapools: protect page_list walk in show_pools()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 30 Jun 2009 18:41:25 +0000 (11:41 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Jul 2009 01:56:00 +0000 (18:56 -0700)
show_pools() walks the page_list of a pool w/o protection against the list
modifications in alloc/free.  Take pool->lock to avoid stomping into
nirvana.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/dmapool.c

index b1f0885dda2275b09baa7d82205f6529efd093b1..3df063706f53e6d579ec0acabace3503a471ba29 100644 (file)
@@ -86,10 +86,12 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf)
                unsigned pages = 0;
                unsigned blocks = 0;
 
+               spin_lock_irq(&pool->lock);
                list_for_each_entry(page, &pool->page_list, page_list) {
                        pages++;
                        blocks += page->in_use;
                }
+               spin_unlock_irq(&pool->lock);
 
                /* per-pool info, no real statistics yet */
                temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n",