riscv: uaccess: fix type of 0 variable on error in get_user()
PATCH 1/1 riscv: uaccess: fix type of 0 variable on error in get_user()
If the get_user(x, ptr) has x as a pointer, then the setting of (x) = 0 is going to produce the following sparse warning, so fix this by forcing the type of 'x' when access_ok() fails.
fs/aio.c:2073:21: warning: Using plain integer as NULL pointer
--- arch/riscv/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/uaccess.h +1 -1
@@ -165,7 +165,7 @@ do { \might_fault (); \access_ok (__p,sizeof (*__p)) ? \__get_user ((x), __p) : \ - ((x) =0 , -EFAULT ); \ + ((x) = (__force __typeof__(x))0, -EFAULT); \ })#define __put_user_asm (insn, x, ptr, err) \
Signature · 7 lines
2.39.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 16 lines · On Thu, 29 Dec 2022 09:05:45 PST (-0800), [email protected] wrote:
If the
get_user(x, ptr)has x as a pointer, then the setting of (x) = 0 is going to produce the following sparse warning, so fix this by forcing the type of 'x' whenaccess_ok()fails.
fs/aio.c:2073:21: warning: Using plain integer as NULL pointerSigned-off-by Ben Dooks <[email protected]>--- arch/riscv/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/include/asm/uaccess.h +0
-0
arch/riscv/include/asm/uaccess.h do { \ · line 171
Quoted 8 lines
arch/riscv/include/asm/uaccess.h +1
-1@@ -165,7 +165,7 @@ do { \might_fault (); \access_ok (__p,sizeof (*__p)) ? \__get_user ((x), __p) : \ - ((x) =0 , -EFAULT ); \ + ((x) = (__force __typeof__(x))0, -EFAULT); \ })#define __put_user_asm (insn, x, ptr, err) \
Looks like arm64 has a pretty similar pattern. They've got the __force __typeof__ already, but given the similarity it might be worth refactoring these to share the error checking code.
I'll give this a bit of time like usual, unless anyone's opposed I'll put it on fixes. I wasn't planning on sending a PR this week anyway due to the holidays.
Thanks!
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 24 lines · Palmer Dabbelt
Quoted 23 lines · On Thu, 29 Dec 2022 09:05:45 PST (-0800), [email protected] wrote:
If the
get_user(x, ptr)has x as a pointer, then the setting of (x) = 0 is going to produce the following sparse warning, so fix this by forcing the type of 'x' whenaccess_ok()fails.
fs/aio.c:2073:21: warning: Using plain integer as NULL pointerSigned-off-by Ben Dooks <[email protected]>--- arch/riscv/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/include/asm/uaccess.h +1
-1@@ -165,7 +165,7 @@ do { \might_fault (); \access_ok (__p,sizeof (*__p)) ? \__get_user ((x), __p) : \ - ((x) =0 , -EFAULT ); \ + ((x) = (__force __typeof__(x))0, -EFAULT); \ })
Quoted 5 lines
arch/riscv/include/asm/uaccess.h do { \ · line 171
Quoted 1 line
arch/riscv/include/asm/uaccess.h +0
-0#define __put_user_asm (insn, x, ptr, err) \Looks like arm64 has a pretty similar pattern. They've got the
__force__typeof__already, but given the similarity it might be worth refactoring these to share the error checking code.
I looked there for an idea on how to fix.
Quoted 5 lines
Reviewed-by Palmer Dabbelt <[email protected]>I'll give this a bit of time like usual, unless anyone's opposed I'll put it on fixes. I wasn't planning on sending a PR this week anyway due to the holidays.
Ok, it's a warning which would be nice to be fixed.
Signature · 9 lines
Ben Dooks, [email protected], http://www.fluff.org/ben/ Large Hadron Colada: A large Pina Colada that makes the universe disappear. _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Palmer Dabbelt
AppliedQuoted 8 lines · Ben Dooks
If the
get_user(x, ptr)has x as a pointer, then the setting of (x) = 0 is going to produce the following sparse warning, so fix this by forcing the type of 'x' whenaccess_ok()fails.
fs/aio.c:2073:21: warning: Using plain integer as NULL pointer[...]
Applied, thanks!
[1/1] riscv: uaccess: fix type of 0 variable on error in get_user()
https://git.kernel.org/palmer/c/b9b916aee671
Best regards,
Signature · 1 line
Palmer Dabbelt <[email protected]>
This patch was applied to riscv/linux.git (fixes) by Palmer Dabbelt <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <[email protected]>:
Quoted 9 lines · On Thu, 29 Dec 2022 17:05:45 +0000 you wrote:
If the
get_user(x, ptr)has x as a pointer, then the setting of (x) = 0 is going to produce the following sparse warning, so fix this by forcing the type of 'x' whenaccess_ok()fails.
fs/aio.c:2073:21: warning: Using plain integer as NULL pointerSigned-off-by Ben Dooks <[email protected]>[...]
Here is the summary with links:
- riscv: uaccess: fix type of 0 variable on error in get_user()
https://git.kernel.org/riscv/c/b9b916aee671
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html