Skip to contentSkip to conversation

powerpc/mm: match variable types to API

PATCH In review Paul Gortmaker 2 participants 2 messages Aug 21, 2012 – Aug 28, 2012 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mm: match variable types to API

From: Joe MacDonald <[email protected]>

sys_subpage_prot() takes an unsigned long for 'addr' then does some stuff with it and the result is stored in a signed int, i, which is eventually used as the size parameter in a copy_from_user call. Update 'i' to be an unsigned long as well and since 'nw' is used in a size_t context which, depending on whether this is 32- or 64-bit may be unsigned int or unsigned long, switch that to a size_t and always be right.

Finally, since we're in the neighbourhood, make the same changes to subpage_prot_clear().

Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/mm/subpage-prot.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/mm/subpage-prot.c +4 -2
index e4f8f1f..7c415dd 100644
@@ -95,7 +95,8 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len)
 	struct mm_struct *mm = current->mm;
 	struct subpage_prot_table *spt = &mm->context.spt;
 	u32 **spm, *spp;
-	int i, nw;
+	unsigned long i;
+	size_t nw;
 	unsigned long next, limit;
 
 	down_write(&mm->mmap_sem);
@@ -144,7 +145,8 @@ long sys_subpage_prot(unsigned long addr, unsigned long len, u32 __user *map)
 	struct mm_struct *mm = current->mm;
 	struct subpage_prot_table *spt = &mm->context.spt;
 	u32 **spm, *spp;
-	int i, nw;
+	unsigned long i;
+	size_t nw;
 	unsigned long next, limit;
 	int err;
 
Signature · 1 line
1.7.11.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Paul Gortmaker

From: Joe MacDonald <[email protected]>

sys_subpage_prot() takes an unsigned long for 'addr' then does some stuff with it and the result is stored in a signed int, i, which is eventually used as the size parameter in a copy_from_user call. Update 'i' to be an unsigned long as well and since 'nw' is used in a size_t context which, depending on whether this is 32- or 64-bit may be unsigned int or unsigned long, switch that to a size_t and always be right.

Quoted 7 lines

Finally, since we're in the neighbourhood, make the same changes to subpage_prot_clear().

Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>

This change won't hurt; in fact it won't make any difference since (a) this code is only ever used on 64-bit and (b) i and nw are restricted to the range 0 .. PTRS_PER_PTE - 1, but I agree the code is slightly cleaner this way.