Skip to content

Commit e5e7e39

Browse files
Ravulapati Vishnu Vardhan Raobroonie
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6588213 commit e5e7e39

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sound/soc/codecs/lpass-tx-macro.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ enum {
242242

243243
struct tx_mute_work {
244244
struct tx_macro *tx;
245-
u32 decimator;
245+
u8 decimator;
246246
struct delayed_work dwork;
247247
};
248248

@@ -635,7 +635,7 @@ static int tx_macro_mclk_enable(struct tx_macro *tx,
635635
return 0;
636636
}
637637

638-
static bool is_amic_enabled(struct snd_soc_component *component, int decimator)
638+
static bool is_amic_enabled(struct snd_soc_component *component, u8 decimator)
639639
{
640640
u16 adc_mux_reg, adc_reg, adc_n;
641641

@@ -849,7 +849,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
849849
struct snd_kcontrol *kcontrol, int event)
850850
{
851851
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
852-
unsigned int decimator;
852+
u8 decimator;
853853
u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg, tx_gain_ctl_reg;
854854
u8 hpf_cut_off_freq;
855855
int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
@@ -1064,7 +1064,8 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
10641064
struct snd_soc_dai *dai)
10651065
{
10661066
struct snd_soc_component *component = dai->component;
1067-
u32 decimator, sample_rate;
1067+
u32 sample_rate;
1068+
u8 decimator;
10681069
int tx_fs_rate;
10691070
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
10701071

@@ -1128,7 +1129,7 @@ static int tx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
11281129
{
11291130
struct snd_soc_component *component = dai->component;
11301131
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
1131-
u16 decimator;
1132+
u8 decimator;
11321133

11331134
/* active decimator not set yet */
11341135
if (tx->active_decimator[dai->id] == -1)

0 commit comments

Comments
 (0)