msm: audio: qdsp6v2: Fix memory leak and error handling
The error handling of apr_reset_workqueue and apr_reset_worker when
NULL should be two seperate checks and hence should have corresponding
appropriate log msgs.
Also there is no need to allocate memory for apr_reset_worker if
apr_reset_workqueue is NULL.
Signed-off-by: Shiv Maliyappanahalli <smaliyap@codeaurora.org>
Change-Id: I220a23729d0fc6dadce144e476a8b2af727fc6b6
diff --git a/arch/arm/mach-msm/qdsp6v2/apr.c b/arch/arm/mach-msm/qdsp6v2/apr.c
index 37428da..541f62f 100644
--- a/arch/arm/mach-msm/qdsp6v2/apr.c
+++ b/arch/arm/mach-msm/qdsp6v2/apr.c
@@ -505,12 +505,19 @@
return;
pr_debug("%s: handle[%p]\n", __func__, handle);
+ if (apr_reset_workqueue == NULL) {
+ pr_err("%s: apr_reset_workqueue is NULL\n", __func__);
+ return;
+ }
+
apr_reset_worker = kzalloc(sizeof(struct apr_reset_work),
- GFP_ATOMIC);
- if (apr_reset_worker == NULL || apr_reset_workqueue == NULL) {
+ GFP_ATOMIC);
+
+ if (apr_reset_worker == NULL) {
pr_err("%s: mem failure\n", __func__);
return;
}
+
apr_reset_worker->handle = handle;
INIT_WORK(&apr_reset_worker->work, apr_reset_deregister);
queue_work(apr_reset_workqueue, &apr_reset_worker->work);