From f2f07591b2de9ba45bbc3eb4f601d1e9a327190b Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Tue, 26 Feb 2019 18:04:18 +0530 Subject: rpc/transport: Missing a ref on dict while creating transport object while creating rpc_tranpsort object, we store a dictionary without taking a ref on dict but it does an unref during the cleaning of the transport object. So the rpc layer expect the caller to take a ref on the dictionary before passing dict to rpc layer. This leads to a lot of confusion across the code base and leads to ref leaks. Semantically, this is not correct. It is the rpc layer responsibility to take a ref when storing it, and free during the cleanup. I'm listing down the total issues or leaks across the code base because of this confusion. These issues are currently present in the upstream master. 1) changelog_rpc_client_init 2) quota_enforcer_init 3) rpcsvc_create_listeners : when there are two transport, like tcp,rdma. 4) quotad_aggregator_init 5) glusterd: init 6) nfs3_init_state 7) server: init 8) client:init This patch does the cleanup according to the semantics. Change-Id: I46373af9630373eb375ee6de0e6f2bbe2a677425 updates: bz#1659708 Signed-off-by: Mohammed Rafi KC --- xlators/mgmt/glusterd/src/glusterd-rebalance.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-rebalance.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index 34b0294474c..5562ebbda37 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -391,6 +391,10 @@ glusterd_rebalance_rpc_create(glusterd_volinfo_t *volinfo) if (!defrag) goto out; + options = dict_new(); + if (!options) + goto out; + GLUSTERD_GET_DEFRAG_SOCK_FILE(sockfile, volinfo); /* Check if defrag sockfile exists in the new location * in /var/run/ , if it does not try the old location @@ -420,7 +424,7 @@ glusterd_rebalance_rpc_create(glusterd_volinfo_t *volinfo) * default timeout of 30mins used for unreliable network connections is * too long for unix domain socket connections. */ - ret = rpc_transport_unix_options_build(&options, sockfile, 600); + ret = rpc_transport_unix_options_build(options, sockfile, 600); if (ret) { gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_UNIX_OP_BUILD_FAIL, "Unix options build failed"); @@ -437,6 +441,8 @@ glusterd_rebalance_rpc_create(glusterd_volinfo_t *volinfo) } ret = 0; out: + if (options) + dict_unref(options); return ret; } -- cgit