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

Commit 2852b361 authored by Banajit Goswami's avatar Banajit Goswami
Browse files

ASoC: msm: q6dspv2: initialize private data before using it



During Compress offload session open, a private data structure
is allocated and registered as parameter for a callback to the
compressed offload driver. All parameters inside the structure
must be initialized before the structure is passed to ASM driver.
This private data structure is sent back as param to the callback
function registered with ASM. The initialization is needed to avoid
NULL pointer dereference inside the callback function, in case ADSP
SSR is triggered right after registering the callback with ASM and
before rest of the initialization of the private data is complete.

CRs-fixed: 989822
Change-Id: I8a64539a6a64fb8c75d06f933a735c70049bce7b
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
parent d3068532
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -1073,20 +1073,6 @@ static int msm_compr_open(struct snd_compr_stream *cstream)
		kfree(prtd);
		return -ENOMEM;
	}
	prtd->audio_client = q6asm_audio_client_alloc(
				(app_cb)compr_event_handler, prtd);
	if (!prtd->audio_client) {
		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;
	}

	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;
	prtd->codec = FORMAT_MP3;
	prtd->bytes_received = 0;
	prtd->bytes_sent = 0;
@@ -1125,6 +1111,21 @@ static int msm_compr_open(struct snd_compr_stream *cstream)

	runtime->private_data = prtd;
	populate_codec_list(prtd);
	prtd->audio_client = q6asm_audio_client_alloc(
				(app_cb)compr_event_handler, prtd);
	if (!prtd->audio_client) {
		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;
		runtime->private_data = NULL;
		kfree(prtd);
		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;

	return 0;
}