Merge "asoc: add NULL check before access pointer"

This commit is contained in:
qctecmdr 2019-03-29 01:39:35 -07:00 committed by Gerrit - the friendly Code Review server
commit 3f2cb16d11
2 changed files with 38 additions and 9 deletions

View File

@ -363,12 +363,17 @@ static int msm_compr_set_volume(struct snd_compr_stream *cstream,
}
rtd = cstream->private_data;
prtd = cstream->runtime->private_data;
component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
if (!rtd || !component || !prtd || !prtd->audio_client) {
if (!rtd || !prtd || !prtd->audio_client) {
pr_err("%s: invalid rtd, prtd or audio client", __func__);
return rc;
}
component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
if (!component) {
pr_err("%s: invalid component\n", __func__);
return rc;
}
pdata = snd_soc_component_get_drvdata(component);
if (prtd->compr_passthr != LEGACY_PCM) {
@ -1810,12 +1815,16 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
}
runtime = cstream->runtime;
soc_prtd = cstream->private_data;
component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
if (!runtime || !soc_prtd || !component) {
pr_err("%s runtime or soc_prtd or component is null\n",
if (!runtime || !soc_prtd) {
pr_err("%s runtime or soc_prtd is null\n",
__func__);
return 0;
}
component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
if (!component) {
pr_err("%s component is null\n", __func__);
return 0;
}
prtd = runtime->private_data;
if (!prtd) {
pr_err("%s prtd is null\n", __func__);
@ -1913,12 +1922,16 @@ static int msm_compr_capture_free(struct snd_compr_stream *cstream)
}
runtime = cstream->runtime;
soc_prtd = cstream->private_data;
component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
if (!runtime || !soc_prtd || !component) {
pr_err("%s runtime or soc_prtd or component is null\n",
__func__);
if (!runtime || !soc_prtd) {
pr_err("%s runtime or soc_prtd is null\n", __func__);
return 0;
}
component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
if (!component) {
pr_err("%s component is null\n", __func__);
return 0;
}
prtd = runtime->private_data;
if (!prtd) {
pr_err("%s prtd is null\n", __func__);

View File

@ -435,7 +435,15 @@ static int msm_transcode_loopback_set_params(struct snd_compr_stream *cstream,
mutex_lock(&trans->lock);
rtd = snd_pcm_substream_chip(cstream);
if (!rtd) {
pr_err("%s: rtd is NULL\n", __func__);
return -EINVAL;
}
component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
if (!component) {
pr_err("%s: component is NULL\n", __func__);
return -EINVAL;
}
pdata = snd_soc_component_get_drvdata(component);
if (cstream->direction == SND_COMPRESS_PLAYBACK) {
@ -606,7 +614,15 @@ static int msm_transcode_loopback_set_metadata(struct snd_compr_stream *cstream,
}
rtd = snd_pcm_substream_chip(cstream);
if (!rtd) {
pr_err("%s: rtd is NULL\n", __func__);
return -EINVAL;
}
component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
if (!component) {
pr_err("%s: component is NULL\n", __func__);
return -EINVAL;
}
pdata = snd_soc_component_get_drvdata(component);
prtd = cstream->runtime->private_data;