summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-01-02 10:36:09 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2022-01-02 10:36:09 -0800
commit859431ac11aef9b4cd7ffa75e94a92a6a41c8623 (patch)
treeb2b6b812e7aba7c0159e05cfc972edde5e00658f /drivers
parent1286cc4893cf356ad6c3a042116981e827dd3680 (diff)
parentc116fe1e1883ad3eda0a1938a9e3275a98aa51a5 (diff)
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Better input validation for compat ioctls and a documentation bugfix for 5.16" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: Docs: Fixes link to I2C specification i2c: validate user data in compat ioctl
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/i2c-dev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index bce0e8bb7852..cf5d049342ea 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -535,6 +535,9 @@ static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned lo
sizeof(rdwr_arg)))
return -EFAULT;
+ if (!rdwr_arg.msgs || rdwr_arg.nmsgs == 0)
+ return -EINVAL;
+
if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
return -EINVAL;