Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bfa3847 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: qdsp6v2: Set freed pointers to NULL"

parents 67374d3f fc12200d
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ struct msm_compr_pdata {
	bool use_legacy_api; /* indicates use older asm apis*/
	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 {
@@ -1323,11 +1324,16 @@ static int msm_compr_playback_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");
@@ -1339,7 +1345,7 @@ static int msm_compr_playback_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);
@@ -1347,10 +1353,11 @@ static int msm_compr_playback_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;
@@ -1395,18 +1402,20 @@ static int msm_compr_playback_open(struct snd_compr_stream *cstream)
	populate_codec_list(prtd);
	prtd->audio_client = q6asm_audio_client_alloc(
				(app_cb)compr_event_handler, prtd);
	if (!prtd->audio_client) {
	if (prtd->audio_client == NULL) {
		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->cstream[rtd->dai_link->be_id] = NULL;
		runtime->private_data = NULL;
		kfree(prtd);
		runtime->private_data = NULL;
		return -ENOMEM;
	}
	pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session);
	prtd->audio_client->perf_mode = false;
	prtd->session_id = prtd->audio_client->session;
	pdata->is_in_use[rtd->dai_link->be_id] = true;

	return 0;
}
@@ -1562,11 +1571,15 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
	q6asm_audio_client_buf_free_contiguous(dir, ac);

	q6asm_audio_client_free(ac);

	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;

@@ -3390,6 +3403,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;
	}

	snd_soc_add_platform_controls(platform, msm_compr_gapless_controls,