glusterd: glusterd memory leak while running "gluster v profile" in a loop

Problem: glusterd has memory leak while running "gluster v profile"
         in a loop

Solution: Resolve leak code path to avoid leak

> Change-Id: Id608703ff6d0ad34ed8f921a5d25544e24cfadcd
> fixes: bz#1685414
> (Cherry pick from commit 9374484917466dff4688d96ff7faa0de1c804a6c)
> (Reviewed on link https://review.gluster.org/#/c/glusterfs/+/22301/)

Change-Id: I1ca118265f97b188f94b3d5cff649ec36cb18ca0
fixes: bz#1685771
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
This commit is contained in:
Mohit Agrawal 2019-03-05 13:39:46 +05:30 committed by Shyamsundar Ranganathan
parent 47ed784e37
commit 0d0b54a9de
2 changed files with 6 additions and 3 deletions

View File

@ -1330,8 +1330,9 @@ out:
if (rsp.op_errstr)
free(rsp.op_errstr);
if (rsp.dict.dict_val)
free(rsp.dict.dict_val);
if (rsp_dict)
dict_unref(rsp_dict);
GF_FREE(peerid);
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
* the caller function.

View File

@ -1653,6 +1653,7 @@ gd_brick_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
char **op_errstr)
{
glusterd_pending_node_t *pending_node = NULL;
glusterd_pending_node_t *tmp = NULL;
struct cds_list_head selected = {
0,
};
@ -1690,7 +1691,7 @@ gd_brick_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
rsp_dict = NULL;
brick_count = 0;
cds_list_for_each_entry(pending_node, &selected, list)
cds_list_for_each_entry_safe(pending_node, tmp, &selected, list)
{
rpc = glusterd_pending_node_get_rpc(pending_node);
if (!rpc) {
@ -1747,6 +1748,7 @@ gd_brick_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
brick_count++;
glusterd_pending_node_put_rpc(pending_node);
GF_FREE(pending_node);
}
pending_node = NULL;