mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
ASoC: msm: qdsp6v2: Set freed pointers to NULL
Set freed pointers to NULL to avoid double free in msm_compr_playback_open and msm_compr_playback_free functions of the compress driver. CRs-Fixed: 2142216 Change-Id: Ifd011dd85dd9f610c7b69dd460f73d26e006cd66 Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
This commit is contained in:
parent
7ae8565f29
commit
976dce7632
1 changed files with 23 additions and 9 deletions
|
@ -99,6 +99,7 @@ struct msm_compr_pdata {
|
|||
bool use_dsp_gapless_mode;
|
||||
struct msm_compr_dec_params *dec_params[MSM_FRONTEND_DAI_MAX];
|
||||
struct msm_compr_ch_map *ch_map[MSM_FRONTEND_DAI_MAX];
|
||||
bool is_in_use[MSM_FRONTEND_DAI_MAX];
|
||||
};
|
||||
|
||||
struct msm_compr_audio {
|
||||
|
@ -1051,11 +1052,16 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
|
|||
{
|
||||
struct snd_compr_runtime *runtime = cstream->runtime;
|
||||
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
||||
struct msm_compr_audio *prtd;
|
||||
struct msm_compr_audio *prtd = NULL;
|
||||
struct msm_compr_pdata *pdata =
|
||||
snd_soc_platform_get_drvdata(rtd->platform);
|
||||
|
||||
pr_debug("%s\n", __func__);
|
||||
if (pdata->is_in_use[rtd->dai_link->be_id] == true) {
|
||||
pr_err("%s: %s is already in use,err: %d ",
|
||||
__func__, rtd->dai_link->cpu_dai_name, -EBUSY);
|
||||
return -EBUSY;
|
||||
}
|
||||
prtd = kzalloc(sizeof(struct msm_compr_audio), GFP_KERNEL);
|
||||
if (prtd == NULL) {
|
||||
pr_err("Failed to allocate memory for msm_compr_audio\n");
|
||||
|
@ -1067,7 +1073,7 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
|
|||
pdata->cstream[rtd->dai_link->be_id] = cstream;
|
||||
pdata->audio_effects[rtd->dai_link->be_id] =
|
||||
kzalloc(sizeof(struct msm_compr_audio_effects), GFP_KERNEL);
|
||||
if (!pdata->audio_effects[rtd->dai_link->be_id]) {
|
||||
if (pdata->audio_effects[rtd->dai_link->be_id] == NULL) {
|
||||
pr_err("%s: Could not allocate memory for effects\n", __func__);
|
||||
pdata->cstream[rtd->dai_link->be_id] = NULL;
|
||||
kfree(prtd);
|
||||
|
@ -1075,10 +1081,11 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
|
|||
}
|
||||
pdata->dec_params[rtd->dai_link->be_id] =
|
||||
kzalloc(sizeof(struct msm_compr_dec_params), GFP_KERNEL);
|
||||
if (!pdata->dec_params[rtd->dai_link->be_id]) {
|
||||
if (pdata->dec_params[rtd->dai_link->be_id] == NULL) {
|
||||
pr_err("%s: Could not allocate memory for dec params\n",
|
||||
__func__);
|
||||
kfree(pdata->audio_effects[rtd->dai_link->be_id]);
|
||||
pdata->audio_effects[rtd->dai_link->be_id] = NULL;
|
||||
pdata->cstream[rtd->dai_link->be_id] = NULL;
|
||||
kfree(prtd);
|
||||
return -ENOMEM;
|
||||
|
@ -1088,7 +1095,9 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
|
|||
if (!prtd->audio_client) {
|
||||
pr_err("%s: Could not allocate memory for client\n", __func__);
|
||||
kfree(pdata->audio_effects[rtd->dai_link->be_id]);
|
||||
pdata->audio_effects[rtd->dai_link->be_id] = NULL;
|
||||
kfree(pdata->dec_params[rtd->dai_link->be_id]);
|
||||
pdata->dec_params[rtd->dai_link->be_id] = NULL;
|
||||
pdata->cstream[rtd->dai_link->be_id] = NULL;
|
||||
kfree(prtd);
|
||||
return -ENOMEM;
|
||||
|
@ -1146,7 +1155,7 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
|
|||
} else {
|
||||
pr_err("%s: Unsupported stream type", __func__);
|
||||
}
|
||||
|
||||
pdata->is_in_use[rtd->dai_link->be_id] = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1241,11 +1250,15 @@ static int msm_compr_free(struct snd_compr_stream *cstream)
|
|||
q6asm_audio_client_buf_free_contiguous(dir, ac);
|
||||
|
||||
q6asm_audio_client_free(ac);
|
||||
|
||||
kfree(pdata->audio_effects[soc_prtd->dai_link->be_id]);
|
||||
pdata->audio_effects[soc_prtd->dai_link->be_id] = NULL;
|
||||
kfree(pdata->dec_params[soc_prtd->dai_link->be_id]);
|
||||
pdata->dec_params[soc_prtd->dai_link->be_id] = NULL;
|
||||
if (pdata->audio_effects[soc_prtd->dai_link->be_id] != NULL) {
|
||||
kfree(pdata->audio_effects[soc_prtd->dai_link->be_id]);
|
||||
pdata->audio_effects[soc_prtd->dai_link->be_id] = NULL;
|
||||
}
|
||||
if (pdata->dec_params[soc_prtd->dai_link->be_id] != NULL) {
|
||||
kfree(pdata->dec_params[soc_prtd->dai_link->be_id]);
|
||||
pdata->dec_params[soc_prtd->dai_link->be_id] = NULL;
|
||||
}
|
||||
pdata->is_in_use[soc_prtd->dai_link->be_id] = false;
|
||||
kfree(prtd);
|
||||
runtime->private_data = NULL;
|
||||
|
||||
|
@ -2779,6 +2792,7 @@ static int msm_compr_probe(struct snd_soc_platform *platform)
|
|||
pdata->dec_params[i] = NULL;
|
||||
pdata->cstream[i] = NULL;
|
||||
pdata->ch_map[i] = NULL;
|
||||
pdata->is_in_use[i] = false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue