diff options
| author | Sultan Alsawaf <sultan@kerneltoast.com> | 2017-03-21 00:37:41 -0700 |
|---|---|---|
| committer | marcost2 <marcostolcachir@gmail.com> | 2021-03-18 19:44:19 -0300 |
| commit | fcd100c186ab16d838b8235cb7f4f51b5a2ae882 (patch) | |
| tree | c3fa2d04ac818c9287c2083732d5d6c0ac0b7759 | |
| parent | da025fbf8b6b64aa721522eafbaf469b60540553 (diff) | |
net: ipc_router: Fix memory leaks when releasing a remote portq10.0-albus
In ipc_router_set_conn(), memory is allocated to a local port for the
conn_info linked list, but the memory for the local ports is never
freed when the remote port is released.
Delete the local ports and free all of their memory when releasing a remote
port to fix the memory leaks. This is just like how memory is freed for the
remote_tx ports.
Change-Id: Id25cd68ae52e985e808d35bbc6c751ab1f129f05
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Albert I <kras@raphielgang.org>
| -rw-r--r-- | net/ipc_router/ipc_router_core.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/ipc_router/ipc_router_core.c b/net/ipc_router/ipc_router_core.c index 8df65d12dc55..853b37242dab 100644 --- a/net/ipc_router/ipc_router_core.c +++ b/net/ipc_router/ipc_router_core.c @@ -1522,6 +1522,27 @@ static void msm_ipc_router_free_resume_tx_port( } /** + * msm_ipc_router_free_conn_info() - Free the local ports + * @rport_ptr: Pointer to the remote port. + * + * This function deletes all the local ports associated with a remote port + * and frees the memory allocated to each local port. + * + * Must be called with rport_ptr->rport_lock_lhb2 locked. + */ +static void msm_ipc_router_free_conn_info( + struct msm_ipc_router_remote_port *rport_ptr) +{ + struct ipc_router_conn_info *conn_info, *tmp_conn_info; + + list_for_each_entry_safe(conn_info, tmp_conn_info, + &rport_ptr->conn_info_list, list) { + list_del(&conn_info->list); + kfree(conn_info); + } +} + +/** * msm_ipc_router_lookup_resume_tx_port() - Lookup resume_tx port list * @rport_ptr: Remote port whose resume_tx port list needs to be looked. * @port_id: Port ID which needs to be looked from the list. @@ -1647,6 +1668,7 @@ static void ipc_router_release_rport(struct kref *ref) mutex_lock(&rport_ptr->rport_lock_lhb2); msm_ipc_router_free_resume_tx_port(rport_ptr); + msm_ipc_router_free_conn_info(rport_ptr); mutex_unlock(&rport_ptr->rport_lock_lhb2); kfree(rport_ptr); } |
