• Krzysztof Adamski's avatar
    regmap: use proper part of work_buf for storing val · 4c90f297
    Krzysztof Adamski authored
    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: default avatarKrzysztof Adamski <krzysztof.adamski@nokia.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    4c90f297
regmap.c 71.9 KB