[PATCH v3 1/3] ARM: Fix some check warnings of tool sparse

From: Zhen Lei
Date: Thu Oct 13 2022 - 22:00:55 EST


Fix the following warnings:
warning: incorrect type in initializer (different address spaces)
expected unsigned short [noderef] __user *register __p
got unsigned short [usertype] *
warning: cast removes address space '__user' of expression

Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
---
arch/arm/kernel/traps.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 20b2db6dcd1ced7..d455c97237e2079 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -188,9 +188,9 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
}
} else {
if (thumb)
- bad = get_user(val, &((u16 *)addr)[i]);
+ bad = get_user(val, &((u16 __user *)addr)[i]);
else
- bad = get_user(val, &((u32 *)addr)[i]);
+ bad = get_user(val, &((u32 __user *)addr)[i]);
}

if (!bad)
@@ -448,9 +448,9 @@ int call_undef_hook(struct pt_regs *regs, unsigned int instr)
asmlinkage void do_undefinstr(struct pt_regs *regs)
{
unsigned int instr;
- void __user *pc;
+ void *pc;

- pc = (void __user *)instruction_pointer(regs);
+ pc = (void *)instruction_pointer(regs);

if (processor_mode(regs) == SVC_MODE) {
#ifdef CONFIG_THUMB2_KERNEL
@@ -494,7 +494,7 @@ asmlinkage void do_undefinstr(struct pt_regs *regs)
}
#endif
arm_notify_die("Oops - undefined instruction", regs,
- SIGILL, ILL_ILLOPC, pc, 0, 6);
+ SIGILL, ILL_ILLOPC, (void __user *)pc, 0, 6);
}
NOKPROBE_SYMBOL(do_undefinstr)

--
2.25.1