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

Commit 64e3b7ea authored by Asish Bhattacharya's avatar Asish Bhattacharya
Browse files

ASoC: msm: ensure check before accessing session private data.



The compressed session needs to be active to set volume to dsp.
Ensure the check to see valid session exist before accessing
private data, else results in kernel panic.

The Memory allocation for driver data also needs to be freed
for failure in session open.

CRs-Fixed: 638817
Change-Id: Ifdce543aa55df420960e9eeff0564f18d9410060
Signed-off-by: default avatarAsish Bhattacharya <asishb@codeaurora.org>
parent 563010bc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -167,6 +167,10 @@ static int msm_compr_set_volume(struct snd_compr_stream *cstream,

	pr_debug("%s: volume_l %d volume_r %d\n",
		__func__, volume_l, volume_r);
	if (!cstream || !cstream->runtime) {
		pr_err("%s: session not active\n", __func__);
		return -EPERM;
	}
	prtd = cstream->runtime->private_data;
	if (prtd && prtd->audio_client) {
		if (volume_l != volume_r) {
@@ -709,6 +713,7 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
		 kzalloc(sizeof(struct msm_compr_audio_effects), GFP_KERNEL);
	if (!pdata->audio_effects[rtd->dai_link->be_id]) {
		pr_err("%s: Could not allocate memory for effects\n", __func__);
		pdata->cstream[rtd->dai_link->be_id] = NULL;
		kfree(prtd);
		return -ENOMEM;
	}
@@ -717,6 +722,8 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
	if (!pdata->dec_params[rtd->dai_link->be_id]) {
		pr_err("%s: Could not allocate memory for dec params\n",
			__func__);
		kfree(pdata->audio_effects[rtd->dai_link->be_id]);
		pdata->cstream[rtd->dai_link->be_id] = NULL;
		kfree(prtd);
		return -ENOMEM;
	}
@@ -726,6 +733,7 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
		pr_err("%s: Could not allocate memory for client\n", __func__);
		kfree(pdata->audio_effects[rtd->dai_link->be_id]);
		kfree(pdata->dec_params[rtd->dai_link->be_id]);
		pdata->cstream[rtd->dai_link->be_id] = NULL;
		kfree(prtd);
		return -ENOMEM;
	}