Skip to content
Commit 23a27722 authored by Alexander Popov's avatar Alexander Popov Committed by Wolfram Sang
Browse files

i2c: dev: prevent ZERO_SIZE_PTR deref in i2cdev_ioctl_rdwr()



i2cdev_ioctl_rdwr() allocates i2c_msg.buf using memdup_user(), which
returns ZERO_SIZE_PTR if i2c_msg.len is zero.

Currently i2cdev_ioctl_rdwr() always dereferences the buf pointer in case
of I2C_M_RD | I2C_M_RECV_LEN transfer. That causes a kernel oops in
case of zero len.

Let's check the len against zero before dereferencing buf pointer.

This issue was triggered by syzkaller.

Signed-off-by: default avatarAlexander Popov <alex.popov@linux.com>
Reviewed-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
[wsa: use '< 1' instead of '!' for easier readability]
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 40d802cb
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment