i2c: i801: Don't silently correct invalid transfer size
authorHeiner Kallweit <hkallweit1@gmail.com>
Sun, 7 Nov 2021 21:57:00 +0000 (22:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:57 +0000 (11:04 +0100)
commitbe9313f755a7bfa02230b15731d07074d5255ecb
treeaf18d2c23e7efdf8362ab739937b8ec5202e1a4b
parentb8526a5003d6c444b4e6e4d9598d735099c76366
i2c: i801: Don't silently correct invalid transfer size

[ Upstream commit effa453168a7eeb8a562ff4edc1dbf9067360a61 ]

If an invalid block size is provided, reject it instead of silently
changing it to a supported value. Especially critical I see the case of
a write transfer with block length 0. In this case we have no guarantee
that the byte we would write is valid. When silently reducing a read to
32 bytes then we don't return an error and the caller may falsely
assume that we returned the full requested data.

If this change should break any (broken) caller, then I think we should
fix the caller.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/busses/i2c-i801.c