Skip to content

Commit

Permalink
percpu: avoid calling __pcpu_ptr_to_addr(NULL)
Browse files Browse the repository at this point in the history
__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 <[email protected]>
Cc: Kamalesh Babulal <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
akpm00 authored and torvalds committed Jan 11, 2010
1 parent 8767ba2 commit 129182e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/percpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,14 +1271,16 @@ 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;

if (!ptr)
return;

addr = __pcpu_ptr_to_addr(ptr);

spin_lock_irqsave(&pcpu_lock, flags);

chunk = pcpu_chunk_addr_search(addr);
Expand Down

0 comments on commit 129182e

Please sign in to comment.