summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-10-11 23:39:13 +0530
committerAmar Tumballi <amarts@redhat.com>2018-10-12 15:38:36 +0000
commitac074e03437faf6f2f0897e6d9e7249ac0599b64 (patch)
treebab874090becde321535740ee0cbfa5dd96e4af8 /cli/src
parentf6789462610ab5bae029cb114fa27453a54c8f9c (diff)
cli: Fix memory leaks reported by ASAN
This patch addresses memory leaks other than 'gf_cli_rsp' response structure. Updates: bz#1633930 Change-Id: Idc5940dca623e33bc01004a9324bc435fc60b006 Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-rpc-ops.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index af097d36034..f03c5813ee5 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -111,6 +111,28 @@ gf_free_xdr_cli_rsp(gf_cli_rsp rsp)
}
}
+static void
+gf_free_xdr_getspec_rsp(gf_getspec_rsp rsp)
+{
+ if (rsp.spec) {
+ free(rsp.spec);
+ }
+ if (rsp.xdata.xdata_val) {
+ free(rsp.xdata.xdata_val);
+ }
+}
+
+static void
+gf_free_xdr_fsm_log_rsp(gf1_cli_fsm_log_rsp rsp)
+{
+ if (rsp.op_errstr) {
+ free(rsp.op_errstr);
+ }
+ if (rsp.fsm_log.fsm_log_val) {
+ free(rsp.fsm_log.fsm_log_val);
+ }
+}
+
int
gf_cli_probe_cbk(struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
@@ -503,6 +525,9 @@ out:
if (dict)
dict_unref(dict);
+ if (rsp.friends.friends_val) {
+ free(rsp.friends.friends_val);
+ }
return ret;
}
@@ -4291,6 +4316,7 @@ gf_cli_getspec_cbk(struct rpc_req *req, struct iovec *iov, int count,
out:
cli_cmd_broadcast_response(ret);
+ gf_free_xdr_getspec_rsp(rsp);
return ret;
}
@@ -5532,6 +5558,11 @@ gf_cli_fsm_log_cbk(struct rpc_req *req, struct iovec *iov, int count,
out:
cli_cmd_broadcast_response(ret);
+ if (dict) {
+ dict_unref(dict);
+ }
+ gf_free_xdr_fsm_log_rsp(rsp);
+
return ret;
}
@@ -7006,6 +7037,10 @@ gf_cli_getwd_cbk(struct rpc_req *req, struct iovec *iov, int count,
out:
cli_cmd_broadcast_response(ret);
+ if (rsp.wd) {
+ free(rsp.wd);
+ }
+
return ret;
}
@@ -8622,6 +8657,9 @@ gf_cli_mount_cbk(struct rpc_req *req, struct iovec *iov, int count,
out:
cli_cmd_broadcast_response(ret);
+ if (rsp.path) {
+ free(rsp.path);
+ }
return ret;
}