From: Andrew Morton Date: Fri, 8 Jan 2010 22:42:39 +0000 (-0800) Subject: percpu: avoid calling __pcpu_ptr_to_addr(NULL) X-Git-Tag: v2.6.33-rc4~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=129182e5626972ac0df85d43a36dd46ad61c64e1;p=platform%2Fkernel%2Flinux-stable.git percpu: avoid calling __pcpu_ptr_to_addr(NULL) __pcpu_ptr_to_addr() can be overridden by the architecture and might not behave well if passed a NULL pointer. So avoid calling it until we have verified that its arg is not NULL. Cc: Rusty Russell Cc: Kamalesh Babulal Acked-by: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/percpu.c b/mm/percpu.c index 442010c..083e7c9 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1271,7 +1271,7 @@ static void pcpu_reclaim(struct work_struct *work) */ void free_percpu(void *ptr) { - void *addr = __pcpu_ptr_to_addr(ptr); + void *addr; struct pcpu_chunk *chunk; unsigned long flags; int off; @@ -1279,6 +1279,8 @@ void free_percpu(void *ptr) if (!ptr) return; + addr = __pcpu_ptr_to_addr(ptr); + spin_lock_irqsave(&pcpu_lock, flags); chunk = pcpu_chunk_addr_search(addr);