]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
i2c: dev: prevent adapter retries and timeout being set as minus value
authorYi Zeng <yizeng@asrmicro.com>
Wed, 9 Jan 2019 07:33:07 +0000 (15:33 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Jan 2019 08:44:24 +0000 (09:44 +0100)
commit96e2cd7a68cf2d2f4b110f915b9d13ca369f72df
tree4995085f16edb3d7fe3a392a530eaeaf743c7f7d
parentfe19dc973bbd10a4e710b316b358d95df32f8d8d
i2c: dev: prevent adapter retries and timeout being set as minus value

commit 6ebec961d59bccf65d08b13fc1ad4e6272a89338 upstream.

If adapter->retries is set to a minus value from user space via ioctl,
it will make __i2c_transfer and __i2c_smbus_xfer skip the calling to
adapter->algo->master_xfer and adapter->algo->smbus_xfer that is
registered by the underlying bus drivers, and return value 0 to all the
callers. The bus driver will never be accessed anymore by all users,
besides, the users may still get successful return value without any
error or information log print out.

If adapter->timeout is set to minus value from user space via ioctl,
it will make the retrying loop in __i2c_transfer and __i2c_smbus_xfer
always break after the the first try, due to the time_after always
returns true.

Signed-off-by: Yi Zeng <yizeng@asrmicro.com>
[wsa: minor grammar updates to commit message]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/i2c-dev.c