regmap: spi: Reserve space for register address/padding
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Thu, 18 Aug 2022 10:48:51 +0000 (13:48 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 18 Aug 2022 14:02:05 +0000 (15:02 +0100)
commitf5723cfc01932c7a8d5c78dbf7e067e537c91439
tree9fec7dcaf848e6adc77cab3745e1038e67d93499
parent568035b01cfb107af8d2e4bd2fb9aea22cf5b868
regmap: spi: Reserve space for register address/padding

Currently the max_raw_read and max_raw_write limits in regmap_spi struct
do not take into account the additional size of the transmitted register
address and padding.  This may result in exceeding the maximum permitted
SPI message size, which could cause undefined behaviour, e.g. data
corruption.

Fix regmap_get_spi_bus() to properly adjust the above mentioned limits
by reserving space for the register address/padding as set in the regmap
configuration.

Fixes: f231ff38b7b2 ("regmap: spi: Set regmap max raw r/w from max_transfer_size")

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Reviewed-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220818104851.429479-1-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap-spi.c