summaryrefslogtreecommitdiff
path: root/tools/lib/python
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2026-07-28 23:00:23 -0700
committerAndi Shyti <andi.shyti@kernel.org>2026-09-30 00:39:51 +0200
commit68f382641f8c8034a7867f7ece8e29ca1ce18601 (patch)
tree5a06e7e17af4aaded5573404fb88cc7712f275e9 /tools/lib/python
parent0da2c96cf69df277275b3e7e57118a34b50c8177 (diff)
downloadlinux-next-68f382641f8c8034a7867f7ece8e29ca1ce18601.tar.gz
linux-next-68f382641f8c8034a7867f7ece8e29ca1ce18601.zip
i2c: smbus: make i2c_smbus_read_block_data() safer
i2c_smbus_read_block_data() is dangerous to use because it may deliver up to I2C_SMBUS_BLOCK_MAX (32) bytes, which may be surprising to the caller. Callers tend to allocate buffers of sizes big enough to hold data from a well-behaving device and do not expect that i2c_smbus_read_block_data() may attempt to write more data than expected. To make i2c_smbus_read_block_data() safer to use, change it so that it accepts size of the supplied buffer as another argument and ensure that it will not copy more data than the size of the buffer. Signal oversized responses with -EMSGSIZE. To allow users to gradually transition to the new API employ some macro trickery allowing calling i2c_smbus_read_block_data() with either 3 or 4 arguments. When called with 3 arguments it is assumed that the buffer size is I2C_SMBUS_BLOCK_MAX bytes. Once everyone is transitioned to the 4 argument form the macros should be removed. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://patch.msgid.link/ammWUROtUGeriY8G@google.com
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions