mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
Merge "ASoC: wcd9330: Add NULL check to avoid crash"
This commit is contained in:
commit
deec3055d5
1 changed files with 39 additions and 9 deletions
|
@ -1232,6 +1232,7 @@ static int tomtom_mad_input_put(struct snd_kcontrol *kcontrol,
|
|||
u32 mic_bias_found = 0;
|
||||
u32 i;
|
||||
int ret = 0;
|
||||
char *mad_input;
|
||||
|
||||
tomtom_mad_input = ucontrol->value.integer.value[0];
|
||||
|
||||
|
@ -1249,8 +1250,14 @@ static int tomtom_mad_input_put(struct snd_kcontrol *kcontrol,
|
|||
|
||||
if (strnstr(tomtom_conn_mad_text[tomtom_mad_input],
|
||||
"ADC", sizeof("ADC"))) {
|
||||
ret = kstrtouint(strpbrk(tomtom_conn_mad_text[tomtom_mad_input]
|
||||
, "123456"), 10, &adc);
|
||||
mad_input = strpbrk(tomtom_conn_mad_text[tomtom_mad_input],
|
||||
"123456");
|
||||
if (!mad_input) {
|
||||
dev_err(codec->dev, "%s: Invalid MAD input %s\n",
|
||||
__func__, tomtom_conn_mad_text[tomtom_mad_input]);
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = kstrtouint(mad_input, 10, &adc);
|
||||
if ((ret < 0) || (adc > 6)) {
|
||||
pr_err("%s: Invalid ADC = %s\n", __func__,
|
||||
tomtom_conn_mad_text[tomtom_mad_input]);
|
||||
|
@ -2067,6 +2074,7 @@ static int wcd9330_put_dec_enum(struct snd_kcontrol *kcontrol,
|
|||
u16 tx_mux_ctl_reg;
|
||||
u8 adc_dmic_sel = 0x0;
|
||||
int ret = 0;
|
||||
char *dec;
|
||||
|
||||
if (ucontrol->value.enumerated.item[0] > e->max - 1)
|
||||
return -EINVAL;
|
||||
|
@ -2085,8 +2093,14 @@ static int wcd9330_put_dec_enum(struct snd_kcontrol *kcontrol,
|
|||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = kstrtouint(strpbrk(dec_name, "123456789"), 10, &decimator);
|
||||
dec = strpbrk(dec_name, "123456789");
|
||||
if (!dec) {
|
||||
dev_err(w->dapm->dev, "%s: decimator index not found\n",
|
||||
__func__);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
ret = kstrtouint(dec, 10, &decimator);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: Invalid decimator = %s\n", __func__, dec_name);
|
||||
ret = -EINVAL;
|
||||
|
@ -2799,8 +2813,15 @@ static int tomtom_codec_enable_dmic(struct snd_soc_dapm_widget *w,
|
|||
s32 *dmic_clk_cnt;
|
||||
unsigned int dmic;
|
||||
int ret;
|
||||
char *wname;
|
||||
|
||||
ret = kstrtouint(strpbrk(w->name, "123456"), 10, &dmic);
|
||||
wname = strpbrk(w->name, "123456");
|
||||
if (!wname) {
|
||||
dev_err(codec->dev, "%s: widget not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = kstrtouint(wname, 10, &dmic);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: Invalid DMIC line on the codec\n", __func__);
|
||||
return -EINVAL;
|
||||
|
@ -3172,7 +3193,7 @@ static int tomtom_codec_enable_dec(struct snd_soc_dapm_widget *w,
|
|||
u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg;
|
||||
u8 dec_hpf_cut_of_freq;
|
||||
int offset;
|
||||
|
||||
char *dec;
|
||||
|
||||
pr_debug("%s %d\n", __func__, event);
|
||||
|
||||
|
@ -3189,7 +3210,15 @@ static int tomtom_codec_enable_dec(struct snd_soc_dapm_widget *w,
|
|||
goto out;
|
||||
}
|
||||
|
||||
ret = kstrtouint(strpbrk(dec_name, "123456789"), 10, &decimator);
|
||||
dec = strpbrk(dec_name, "123456789");
|
||||
if (!dec) {
|
||||
dev_err(codec->dev, "%s: decimator index not found\n",
|
||||
__func__);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = kstrtouint(dec, 10, &decimator);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: Invalid decimator = %s\n", __func__, dec_name);
|
||||
ret = -EINVAL;
|
||||
|
@ -4812,8 +4841,9 @@ static int tomtom_set_channel_map(struct snd_soc_dai *dai,
|
|||
struct wcd9xxx_codec_dai_data *dai_data = NULL;
|
||||
struct tomtom_priv *tomtom = snd_soc_codec_get_drvdata(dai->codec);
|
||||
struct wcd9xxx *core = dev_get_drvdata(dai->codec->dev->parent);
|
||||
if (!tx_slot && !rx_slot) {
|
||||
pr_err("%s: Invalid\n", __func__);
|
||||
if (!tx_slot || !rx_slot) {
|
||||
pr_err("%s: Invalid tx_slot=%p, rx_slot=%p\n",
|
||||
__func__, tx_slot, rx_slot);
|
||||
return -EINVAL;
|
||||
}
|
||||
pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
|
||||
|
|
Loading…
Reference in a new issue