Merge "dsp-kernel: Handle memory leak in fastrpc file free"

This commit is contained in:
QCTECMDR Service
2024-07-25 02:06:23 -07:00
committed by Gerrit - the friendly Code Review server

View File

@@ -6029,16 +6029,8 @@ skip_dmainvoke_wait:
is_locked = false; is_locked = false;
spin_unlock_irqrestore(&fl->apps->hlock, irq_flags); spin_unlock_irqrestore(&fl->apps->hlock, irq_flags);
if (!fl->sctx) { if (!fl->sctx)
spin_lock_irqsave(&me->hlock, irq_flags); goto bail;
/* Reset the tgid usage to false */
if (fl->tgid_frpc != -1)
frpc_tgid_usage_array[fl->tgid_frpc] = false;
spin_unlock_irqrestore(&me->hlock, irq_flags);
kfree(fl);
fl = NULL;
return;
}
//Dummy wake up to exit Async worker thread //Dummy wake up to exit Async worker thread
spin_lock_irqsave(&fl->aqlock, flags); spin_lock_irqsave(&fl->aqlock, flags);
@@ -6092,23 +6084,22 @@ skip_dmainvoke_wait:
if (fl->device && is_driver_closed) if (fl->device && is_driver_closed)
device_unregister(&fl->device->dev); device_unregister(&fl->device->dev);
spin_lock_irqsave(&me->hlock, irq_flags);
/* Reset the tgid usage to false */
if (fl->tgid_frpc != -1)
frpc_tgid_usage_array[fl->tgid_frpc] = false;
spin_unlock_irqrestore(&me->hlock, irq_flags);
VERIFY(err, VALID_FASTRPC_CID(cid)); VERIFY(err, VALID_FASTRPC_CID(cid));
if (!err && fl->sctx) if (!err && fl->sctx)
fastrpc_session_free(&fl->apps->channel[cid], fl->sctx); fastrpc_session_free(&fl->apps->channel[cid], fl->sctx);
if (!err && fl->secsctx) if (!err && fl->secsctx)
fastrpc_session_free(&fl->apps->channel[cid], fl->secsctx); fastrpc_session_free(&fl->apps->channel[cid], fl->secsctx);
for (i = 0; i < (DSPSIGNAL_NUM_SIGNALS / DSPSIGNAL_GROUP_SIZE); i++) for (i = 0; i < (DSPSIGNAL_NUM_SIGNALS / DSPSIGNAL_GROUP_SIZE); i++)
kfree(fl->signal_groups[i]); kfree(fl->signal_groups[i]);
mutex_destroy(&fl->signal_create_mutex);
fastrpc_remote_buf_list_free(fl); fastrpc_remote_buf_list_free(fl);
bail:
spin_lock_irqsave(&me->hlock, irq_flags);
/* Reset the tgid usage to false */
if (fl->tgid_frpc != -1)
frpc_tgid_usage_array[fl->tgid_frpc] = false;
spin_unlock_irqrestore(&me->hlock, irq_flags);
mutex_destroy(&fl->signal_create_mutex);
mutex_destroy(&fl->map_mutex); mutex_destroy(&fl->map_mutex);
mutex_destroy(&fl->internal_map_mutex); mutex_destroy(&fl->internal_map_mutex);
kfree(fl->dev_pm_qos_req); kfree(fl->dev_pm_qos_req);