From 7e2b30f53ad1402f71dc3bb32ca936ba423f3e1c Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Tue, 13 Feb 2018 19:24:40 +0530 Subject: [PATCH] ASoC: msm: qdsp6v2: Fix memory allocation issue in afe_sidetone When afe sidetone params are set, memory allocation is not done before packing the param data. Allocate memory before packing the param data to fix this. CRs-Fixed: 2189218 Change-Id: I38cc5a1a948228235e178f46bfce99fa8dec3bd8 Signed-off-by: Aditya Bavanari --- sound/soc/msm/qdsp6v2/q6afe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/msm/qdsp6v2/q6afe.c b/sound/soc/msm/qdsp6v2/q6afe.c index d0c1677acb16..96580207e676 100644 --- a/sound/soc/msm/qdsp6v2/q6afe.c +++ b/sound/soc/msm/qdsp6v2/q6afe.c @@ -4922,6 +4922,13 @@ static int afe_sidetone(u16 tx_port_id, u16 rx_port_id, bool enable) mid = st_cal_info->mid; mutex_unlock(&this_afe.cal_data[cal_index]->lock); + packed_param_size = + sizeof(param_hdr) * 2 + sizeof(gain_data) + sizeof(cfg_data); + packed_param_data = kzalloc(packed_param_size, GFP_KERNEL); + if (!packed_param_data) + return -ENOMEM; + packed_param_size = 0; + /* Set gain data. */ param_hdr.module_id = AFE_MODULE_LOOPBACK; param_hdr.instance_id = INSTANCE_ID_0;