Message ID | 20220411180752.36920-2-andriy.shevchenko@linux.intel.com |
---|---|
State | Accepted |
Commit | aef80e2fbe3ec6264e935cebfb8fa3367cb1e7b0 |
Headers | show |
Series | [v1,1/2] i2c: dev: check return value when calling dev_set_name() | expand |
On Mon, Apr 11, 2022 at 09:07:52PM +0300, Andy Shevchenko wrote: > Sparse has warned us about wrong address space for user pointers: > > i2c-dev.c:561:50: warning: incorrect type in initializer (different address spaces) > i2c-dev.c:561:50: expected unsigned char [usertype] *buf > i2c-dev.c:561:50: got void [noderef] __user * > > Force cast the pointer to (__u8 *) that is used by I²C core code. > > Note, this is an additional fix to the previously addressed similar issue > in the I2C_RDWR case in the same function. > > Fixes: 3265a7e6b41b ("i2c: dev: Add __user annotation") > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Applied to for-current, thanks!
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 6fd2b6718b08..ab0adaa130da 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -557,7 +557,7 @@ static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned lo .addr = umsg.addr, .flags = umsg.flags, .len = umsg.len, - .buf = compat_ptr(umsg.buf) + .buf = (__force __u8 *)compat_ptr(umsg.buf), }; }
Sparse has warned us about wrong address space for user pointers: i2c-dev.c:561:50: warning: incorrect type in initializer (different address spaces) i2c-dev.c:561:50: expected unsigned char [usertype] *buf i2c-dev.c:561:50: got void [noderef] __user * Force cast the pointer to (__u8 *) that is used by I²C core code. Note, this is an additional fix to the previously addressed similar issue in the I2C_RDWR case in the same function. Fixes: 3265a7e6b41b ("i2c: dev: Add __user annotation") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/i2c/i2c-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)