Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Make rheap safe for spinlocks

The rheap allocation function, rh_alloc, could call kmalloc with GFP_KERNEL.
This can sleep, which means you couldn't hold a spinlock while called rh_alloc.
Change all kmalloc calls to use GFP_ATOMIC so that it won't sleep. This is
safe because only small blocks are allocated.

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

authored by

Timur Tabi and committed by
Kumar Gala
3a2f020c 998c6103

+2 -2
+2 -2
arch/powerpc/lib/rheap.c
··· 54 54 55 55 new_blocks = max_blocks - info->max_blocks; 56 56 57 - block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_KERNEL); 57 + block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC); 58 58 if (block == NULL) 59 59 return -ENOMEM; 60 60 ··· 258 258 if ((alignment & (alignment - 1)) != 0) 259 259 return ERR_PTR(-EINVAL); 260 260 261 - info = kmalloc(sizeof(*info), GFP_KERNEL); 261 + info = kmalloc(sizeof(*info), GFP_ATOMIC); 262 262 if (info == NULL) 263 263 return ERR_PTR(-ENOMEM); 264 264