dsp: allocate contiguous memory for version information
Allocate contiguous memory for version information instead of splitting
it across the stack and heap to centralize memory and improve
readability.
CRs-Fixed: 2104576
Signed-off-by: Siena Richard <sienar@codeaurora.org>
Change-Id: Id7b5942522da6312da57bfef3d3c0b55934fe1d7
diff --git a/dsp/q6voice.c b/dsp/q6voice.c
index 7cd340f..fa338b2 100644
--- a/dsp/q6voice.c
+++ b/dsp/q6voice.c
@@ -4066,8 +4066,8 @@
static int voice_get_avcs_version_per_service(uint32_t service_id)
{
int ret = 0;
- size_t svc_size;
- struct avcs_fwk_ver_info ver_info = {{0}, NULL};
+ size_t ver_size;
+ struct avcs_fwk_ver_info *ver_info = NULL;
if (service_id == AVCS_SERVICE_ID_ALL) {
pr_err("%s: Invalid service id: %d", __func__,
@@ -4075,19 +4075,20 @@
return -EINVAL;
}
- svc_size = sizeof(struct avs_svc_api_info);
- ver_info.services = kzalloc(svc_size, GFP_KERNEL);
- if (ver_info.services == NULL)
+ ver_size = sizeof(struct avcs_get_fwk_version) +
+ sizeof(struct avs_svc_api_info);
+ ver_info = kzalloc(ver_size, GFP_KERNEL);
+ if (ver_info == NULL)
return -ENOMEM;
- ret = q6core_get_service_version(service_id, &ver_info, svc_size);
+ ret = q6core_get_service_version(service_id, ver_info, ver_size);
if (ret < 0)
goto done;
- ret = ver_info.services[0].api_version;
+ ret = ver_info->services[0].api_version;
common.is_avcs_version_queried = true;
done:
- kfree(ver_info.services);
+ kfree(ver_info);
return ret;
}