ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
authorRavulapati Vishnu Vardhan Rao <quic_visr@quicinc.com>
Sat, 4 Mar 2023 08:07:02 +0000 (13:37 +0530)
committerMark Brown <broonie@kernel.org>
Sun, 5 Mar 2023 23:36:38 +0000 (23:36 +0000)
commite5e7e398f6bb7918dab0612eb6991f7bae95520d
tree7199be5b3b8a57c2a3dcd276027c502530e8b292
parent65882134bc622a1e57bd5928ac588855ea2e3ddd
ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds

When we run syzkaller we get below Out of Bound.
    "KASAN: slab-out-of-bounds Read in regcache_flat_read"

    Below is the backtrace of the issue:

    dump_backtrace+0x0/0x4c8
    show_stack+0x34/0x44
    dump_stack_lvl+0xd8/0x118
    print_address_description+0x30/0x2d8
    kasan_report+0x158/0x198
    __asan_report_load4_noabort+0x44/0x50
    regcache_flat_read+0x10c/0x110
    regcache_read+0xf4/0x180
    _regmap_read+0xc4/0x278
    _regmap_update_bits+0x130/0x290
    regmap_update_bits_base+0xc0/0x15c
    snd_soc_component_update_bits+0xa8/0x22c
    snd_soc_component_write_field+0x68/0xd4
    tx_macro_digital_mute+0xec/0x140

    Actually There is no need to have decimator with 32 bits.
    By limiting the variable with short type u8 issue is resolved.

Signed-off-by: Ravulapati Vishnu Vardhan Rao <quic_visr@quicinc.com>
Link: https://lore.kernel.org/r/20230304080702.609-1-quic_visr@quicinc.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/lpass-tx-macro.c