]> asedeno.scripts.mit.edu Git - linux.git/commit
regmap: use proper part of work_buf for storing val
authorKrzysztof Adamski <krzysztof.adamski@nokia.com>
Thu, 30 Nov 2017 14:09:15 +0000 (15:09 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 19 Dec 2017 10:55:40 +0000 (10:55 +0000)
commit4c90f297ffcffb84e8667e4f447aeaba52a37220
treebeed486acac68d84f5990beb84afad66dfa70689
parent4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323
regmap: use proper part of work_buf for storing val

The map->work_buf is a buffer preallocated in __regmap_init() with size
allowing it to store all 3 parts of a buffer - reg, pad and val. While
reg and val parts are always properly setup before each transaction, the
pad part is left at its default value (zeros). Until it is overwritten,
that is.

_regmap_bus_read(), when calling _regmap_raw_read() uses beginning of
work_buf as a place to store data read. Usually that is fine but if
val_bits > reg_bits && pad_bits > 0, padding area of work_buf() may get
overwritten. Since padding is not zeroed before each transaction,
garbage will be used on next calls.

This patch moves the val pointer used for _regmap_raw_read() to point
to a part of work_buf intended for storing value read.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap.c