mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-01 19:34:35 +08:00
HID: ft260: fix a NULL pointer dereference in ft260_i2c_write
The zero-length passed into the ft260_i2c_write() triggered the NULL pointer dereference in the debug message on data[0] access. Since the controller does not support a write of zero length, let's not allow it. Before: $ sudo i2ctransfer -y 13 w0@0x51 Killed After: $ sudo i2ctransfer -y 13 w0@0x51 Error: Sending messages failed: Invalid argument Reported-by: Enrik Berkhan <Enrik.Berkhan@inka.de> Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
4b3da6853a
commit
c2500bdffe
@ -409,6 +409,9 @@ static int ft260_i2c_write(struct ft260_device *dev, u8 addr, u8 *data,
|
||||
struct ft260_i2c_write_request_report *rep =
|
||||
(struct ft260_i2c_write_request_report *)dev->write_buf;
|
||||
|
||||
if (len < 1)
|
||||
return -EINVAL;
|
||||
|
||||
rep->flag = FT260_FLAG_START;
|
||||
|
||||
do {
|
||||
|
Loading…
Reference in New Issue
Block a user