2018-12-10 06:52:53

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v3] powerpc/uaccess: fix warning/error with access_ok()

With the following piece of code, the following compilation warning
is encountered:

if (_IOC_DIR(ioc) != _IOC_NONE) {
int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;

if (!access_ok(verify, ioarg, _IOC_SIZE(ioc))) {

drivers/platform/test/dev.c: In function 'my_ioctl':
drivers/platform/test/dev.c:219:7: warning: unused variable 'verify' [-Wunused-variable]
int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;

This patch fixes it by referencing 'type' in the macro allthough
doing nothing with it.

Signed-off-by: Christophe Leroy <[email protected]>
---
v3: not changing __access_ok() anymyre, only referencing type in access_ok()

v2: fixed the three direct users of __access_ok()

arch/powerpc/include/asm/uaccess.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 15bea9a0f260..ebc0b916dcf9 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -63,7 +63,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size,
#endif

#define access_ok(type, addr, size) \
- (__chk_user_ptr(addr), \
+ (__chk_user_ptr(addr), (void)(type), \
__access_ok((__force unsigned long)(addr), (size), get_fs()))

/*
--
2.13.3



2018-12-23 11:07:10

by Michael Ellerman

[permalink] [raw]
Subject: Re: [v3] powerpc/uaccess: fix warning/error with access_ok()

On Mon, 2018-12-10 at 06:50:09 UTC, Christophe Leroy wrote:
> With the following piece of code, the following compilation warning
> is encountered:
>
> if (_IOC_DIR(ioc) != _IOC_NONE) {
> int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
>
> if (!access_ok(verify, ioarg, _IOC_SIZE(ioc))) {
>
> drivers/platform/test/dev.c: In function 'my_ioctl':
> drivers/platform/test/dev.c:219:7: warning: unused variable 'verify' [-Wunused-variable]
> int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
>
> This patch fixes it by referencing 'type' in the macro allthough
> doing nothing with it.
>
> Signed-off-by: Christophe Leroy <[email protected]>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/05a4ab823983d9136a460b7b5e0d49

cheers