Merge "ASoC: codecs: add null check before use"

This commit is contained in:
qctecmdr
2021-08-28 21:21:19 -07:00
committato da Gerrit - the friendly Code Review server

Vedi File

@@ -132,9 +132,20 @@ static int swr_dmic_tx_master_port_get(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct swr_dmic_priv *swr_dmic = snd_soc_component_get_drvdata(component);
struct swr_dmic_priv *swr_dmic = NULL;
int ret = 0;
int slave_port_idx;
unsigned int slave_port_idx = SWR_DMIC_MAX_PORTS;
if (NULL == component) {
pr_err("%s: swr dmic component is NULL\n", __func__);
return -EINVAL;
}
swr_dmic = snd_soc_component_get_drvdata(component);
if (NULL == swr_dmic) {
pr_err("%s: swr_dmic_priv is NULL\n", __func__);
return -EINVAL;
}
ret = swr_dmic_tx_get_slave_port_type_idx(kcontrol->id.name,
&slave_port_idx);
@@ -143,6 +154,11 @@ static int swr_dmic_tx_master_port_get(struct snd_kcontrol *kcontrol,
return ret;
}
if (slave_port_idx >= SWR_DMIC_MAX_PORTS) {
pr_err("%s: invalid slave port id\n", __func__);
return -EINVAL;
}
ucontrol->value.integer.value[0] =
swr_dmic_get_master_port_val(
swr_dmic->tx_master_port_map[slave_port_idx]);
@@ -158,9 +174,21 @@ static int swr_dmic_tx_master_port_put(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct swr_dmic_priv *swr_dmic = snd_soc_component_get_drvdata(component);
struct swr_dmic_priv *swr_dmic = NULL;
int ret = 0;
unsigned int slave_port_idx = SWR_DMIC_MAX_PORTS, idx = 0;
unsigned int slave_port_idx = SWR_DMIC_MAX_PORTS;
unsigned int idx = 0;
if (NULL == component) {
pr_err("%s: swr dmic component is NULL\n", __func__);
return -EINVAL;
}
swr_dmic = snd_soc_component_get_drvdata(component);
if (NULL == swr_dmic) {
pr_err("%s: swr_dmic_priv is NULL\n", __func__);
return -EINVAL;
}
ret = swr_dmic_tx_get_slave_port_type_idx(kcontrol->id.name,
&slave_port_idx);
@@ -169,6 +197,11 @@ static int swr_dmic_tx_master_port_put(struct snd_kcontrol *kcontrol,
return ret;
}
if (slave_port_idx >= SWR_DMIC_MAX_PORTS) {
pr_err("%s: invalid slave port id\n", __func__);
return -EINVAL;
}
idx = ucontrol->value.enumerated.item[0];
if (idx < 0 || idx >= ARRAY_SIZE(swr_master_channel_map))
return -EINVAL;