Commit 129182e5626972ac0df85d43a36dd46ad61c64e1

Authored by Andrew Morton
Committed by Linus Torvalds
1 parent 8767ba2796

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 <rusty@rustcorp.com.au>
Cc: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

... ... @@ -1271,13 +1271,15 @@
1271 1271 */
1272 1272 void free_percpu(void *ptr)
1273 1273 {
1274   - void *addr = __pcpu_ptr_to_addr(ptr);
  1274 + void *addr;
1275 1275 struct pcpu_chunk *chunk;
1276 1276 unsigned long flags;
1277 1277 int off;
1278 1278  
1279 1279 if (!ptr)
1280 1280 return;
  1281 +
  1282 + addr = __pcpu_ptr_to_addr(ptr);
1281 1283  
1282 1284 spin_lock_irqsave(&pcpu_lock, flags);
1283 1285