HID: ft260: check data size in ft260_smbus_write()
authorMichael Zaidman <michael.zaidman@gmail.com>
Tue, 13 Apr 2021 15:12:00 +0000 (18:12 +0300)
committerJiri Kosina <jkosina@suse.cz>
Wed, 5 May 2021 12:32:46 +0000 (14:32 +0200)
commitb45ef5db7bf268f6851bb5395d60301338374abc
tree9d8d3b74b3bd109eb566c8ff28033907327a8dd0
parentb0d713c60c75cdd04bf8ad8cfb046c8530709de3
HID: ft260: check data size in ft260_smbus_write()

The SMbus block transaction limits the number of bytes transferred to 32,
but nothing prevents a user from specifying via ioctl a larger data size
than the ft260 can handle in a single transfer.

i2cdev_ioctl_smbus()
   --> i2c_smbus_xfer
       --> __i2c_smbus_xfer
           --> ft260_smbus_xfer
               --> ft260_smbus_write

This patch adds data size checking in the ft260_smbus_write().

Fixes: 98189a0adfa0 ("HID: ft260: add usb hid to i2c host bridge driver")
Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-ft260.c