i2c: i2c-dev: Add __user annotation
Subsystems (2)
PATCH 1/1 i2c: i2c-dev: Add __user annotation
Fix Sparse warnings:drivers/i2c/i2c-dev.c:546:19: warning: incorrect type in assignment (different address spaces) drivers/i2c/i2c-dev.c:549:53: warning: incorrect type in argument 2 (different address spaces)
compat_ptr() returns a pointer tagged __user which gets assigned to a pointer missing the __user annotation. The same pointer is passed to copy_from_user() as an argument where it is expected to have the __user annotation. Fix both by adding the __user annotation to the pointer.
--- drivers/i2c/i2c-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-dev.c +1 -1
@@ -526,7 +526,7 @@ static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned loreturn put_user (funcs, (compat_ulong_t __user *)arg);case I2C_RDWR : {struct i2c_rdwr_ioctl_data32 rdwr_arg; -struct i2c_msg32 *p; +struct i2c_msg32 __user *p;struct i2c_msg *rdwr_pa;int i;
Signature · 1 line
2.25.1
Quoted 10 lines · Andreas Hecht
Fix Sparse warnings:
drivers/i2c/i2c-dev.c:546:19: warning: incorrect type in assignment (different address spaces)drivers/i2c/i2c-dev.c:549:53: warning: incorrect type in argument 2 (different address spaces)
compat_ptr()returns a pointer tagged__userwhich gets assigned to a pointer missing the__userannotation. The same pointer is passed tocopy_from_user()as an argument where it is expected to have the__userannotation. Fix both by adding the__userannotation to the pointer.Signed-off-by Andreas Hecht <[email protected]>
Nice catch. Applied to for-current, thanks!