diff options
author | Isaac J. Manjarres <isaacm@codeaurora.org> | 2018-09-04 09:38:58 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2020-10-30 01:20:51 -0700 |
commit | 2b9df61e86ec796eb06138bb8d576669b5b1e3d5 (patch) | |
tree | 828bc023bda26ddb7952796e63dd11f19a2d610d /drivers/soc | |
parent | 46ca60ba8377348bd6a874845475b68b8c8e5ff6 (diff) |
soc: qcom: service-locator: Free PD list after client use
Currently, when a client invokes the service-locator to get
the domain list for a service, a data structure is dynamically
allocated to hold this information, and that is given to the
client for use. However, after the client uses the domain list,
the data structure is not freed, resulting in a memory leak.
Free domain list data structure after client use to fix
memory leak.
Change-Id: I2b87afefbb35c2c296b4267450fa3152e3725ab9
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Diffstat (limited to 'drivers/soc')
-rw-r--r-- | drivers/soc/qcom/service-locator.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/soc/qcom/service-locator.c b/drivers/soc/qcom/service-locator.c index 52355699e4f3..7d7cff136689 100644 --- a/drivers/soc/qcom/service-locator.c +++ b/drivers/soc/qcom/service-locator.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2017, 2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -251,7 +251,6 @@ static int service_locator_send_msg(struct pd_qmi_client_data *pd) req->domain_offset_valid = true; req->domain_offset = 0; - pd->domain_list = NULL; do { req->domain_offset += domains_read; rc = servreg_loc_send_msg(&req_desc, &resp_desc, req, resp, @@ -281,6 +280,7 @@ static int service_locator_send_msg(struct pd_qmi_client_data *pd) pr_err("Service Locator DB updated for client %s\n", pd->client_name); kfree(pd->domain_list); + pd->domain_list = NULL; rc = -EAGAIN; goto out; } @@ -360,7 +360,7 @@ int get_service_location(char *client_name, char *service_name, goto err; } - pqcd = kmalloc(sizeof(struct pd_qmi_client_data), GFP_KERNEL); + pqcd = kzalloc(sizeof(struct pd_qmi_client_data), GFP_KERNEL); if (!pqcd) { rc = -ENOMEM; pr_err("Allocation failed\n"); @@ -401,7 +401,7 @@ static void pd_locator_work(struct work_struct *work) pr_err("Unable to connect to service locator!, rc = %d\n", rc); pdqw->notifier->notifier_call(pdqw->notifier, LOCATOR_DOWN, NULL); - goto err; + goto err_init_servloc; } rc = service_locator_send_msg(data); if (rc) { @@ -409,11 +409,13 @@ static void pd_locator_work(struct work_struct *work) data->service_name, data->client_name, rc); pdqw->notifier->notifier_call(pdqw->notifier, LOCATOR_DOWN, NULL); - goto err; + goto err_servloc_send_msg; } pdqw->notifier->notifier_call(pdqw->notifier, LOCATOR_UP, data); -err: +err_servloc_send_msg: + kfree(data->domain_list); +err_init_servloc: kfree(data); kfree(pdqw); } |