diff --git a/sound/soc/codecs/wcd9xxx-common-v2.c b/sound/soc/codecs/wcd9xxx-common-v2.c index 615922274690..f1b147aafd84 100644 --- a/sound/soc/codecs/wcd9xxx-common-v2.c +++ b/sound/soc/codecs/wcd9xxx-common-v2.c @@ -198,6 +198,11 @@ void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) pr_debug("%s, impedance not in range = %d\n", __func__, imped); return; } + if (index >= ARRAY_SIZE(imped_table)) { + pr_debug("%s, impedance index not in range = %d\n", __func__, + index); + return; + } for (i = 0; i < MAX_IMPED_PARAMS; i++) snd_soc_update_bits(codec, imped_table[index][i].reg, imped_table[index][i].mask,