mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 23:24:22 -04:00
msm: mhi_dev: UCI memory leak fix
mhi_init_read_chan() allocates max_packet_size*nr_trbs for async client for inbound channel. Multiple open/close of channels can cause memory leak. Adding free operation during channel release to resolve this. Change-Id: I7be4d47d28140a4d04b5070cb7db776a7f909238 Signed-off-by: Subramanian Ananthanarayanan <skananth@codeaurora.org> Signed-off-by: Gauri Joshi <gaurjosh@codeaurora.org>
This commit is contained in:
parent
7f1d9ff41a
commit
c4c214940e
1 changed files with 15 additions and 1 deletions
|
|
@ -1069,12 +1069,20 @@ static int mhi_uci_client_release(struct inode *mhi_inode,
|
|||
struct file *file_handle)
|
||||
{
|
||||
struct uci_client *uci_handle = file_handle->private_data;
|
||||
int count = 0;
|
||||
const struct chan_attr *in_chan_attr;
|
||||
int count = 0, i;
|
||||
struct mhi_req *ureq;
|
||||
|
||||
if (!uci_handle)
|
||||
return -EINVAL;
|
||||
|
||||
in_chan_attr = uci_handle->in_chan_attr;
|
||||
if (!in_chan_attr) {
|
||||
uci_log(UCI_DBG_ERROR, "Null channel attributes for chan %d\n",
|
||||
uci_handle->in_chan);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_sub_return(1, &uci_handle->ref_count)) {
|
||||
uci_log(UCI_DBG_DBG, "Client close chan %d, ref count 0x%x\n",
|
||||
iminor(mhi_inode),
|
||||
|
|
@ -1133,6 +1141,12 @@ static int mhi_uci_client_release(struct inode *mhi_inode,
|
|||
iminor(mhi_inode), count);
|
||||
}
|
||||
|
||||
for (i = 0; i < (in_chan_attr->nr_trbs); i++) {
|
||||
kfree(uci_handle->in_buf_list[i].addr);
|
||||
uci_handle->in_buf_list[i].addr = NULL;
|
||||
uci_handle->in_buf_list[i].buf_size = 0;
|
||||
}
|
||||
|
||||
atomic_set(&uci_handle->read_data_ready, 0);
|
||||
atomic_set(&uci_handle->write_data_ready, 0);
|
||||
file_handle->private_data = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue