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

sparc32: mm: Fix argument checking in __srmmu_get_nocache()

The 'size' argument to __srmmu_get_nocache() is a number of bytes not
a shift value, so fix up the sanity checking to treat it properly.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Will Deacon and committed by
David S. Miller
ed894bf5 24085f70

+6 -6
+6 -6
arch/sparc/mm/srmmu.c
··· 175 175 */ 176 176 static void *__srmmu_get_nocache(int size, int align) 177 177 { 178 - int offset; 178 + int offset, minsz = 1 << SRMMU_NOCACHE_BITMAP_SHIFT; 179 179 unsigned long addr; 180 180 181 - if (size < SRMMU_NOCACHE_BITMAP_SHIFT) { 181 + if (size < minsz) { 182 182 printk(KERN_ERR "Size 0x%x too small for nocache request\n", 183 183 size); 184 - size = SRMMU_NOCACHE_BITMAP_SHIFT; 184 + size = minsz; 185 185 } 186 - if (size & (SRMMU_NOCACHE_BITMAP_SHIFT - 1)) { 187 - printk(KERN_ERR "Size 0x%x unaligned int nocache request\n", 186 + if (size & (minsz - 1)) { 187 + printk(KERN_ERR "Size 0x%x unaligned in nocache request\n", 188 188 size); 189 - size += SRMMU_NOCACHE_BITMAP_SHIFT - 1; 189 + size += minsz - 1; 190 190 } 191 191 BUG_ON(align > SRMMU_NOCACHE_ALIGN_MAX); 192 192