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/nfs/server/src/acl3.c | 5 +++++ xlators/nfs/server/src/mount3.c | 5 +++++ xlators/nfs/server/src/nlm4.c | 7 +++++++ 3 files changed, 17 insertions(+) (limited to 'xlators/nfs/server/src') diff --git a/xlators/nfs/server/src/acl3.c b/xlators/nfs/server/src/acl3.c index 0eca45d8a3e..2ede24b7bf5 100644 --- a/xlators/nfs/server/src/acl3.c +++ b/xlators/nfs/server/src/acl3.c @@ -787,9 +787,14 @@ acl3svc_init(xlator_t *nfsx) goto err; } + if (options) + dict_unref(options); + acl3_inited = _gf_true; return &acl3prog; err: + if (options) + dict_unref(options); return NULL; } diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index 726dc293af6..396809cb2c2 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -4102,8 +4102,13 @@ mnt3svc_init(xlator_t *nfsx) gf_msg_debug(GF_MNT, GF_LOG_DEBUG, "Thread creation failed"); } } + if (options) + dict_unref(options); + return &mnt3prog; err: + if (options) + dict_unref(options); return NULL; } diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index a341ebd6638..c3c1453a091 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -1121,6 +1121,8 @@ nlm4_establish_callback(nfs3_call_state_t *cs, call_frame_t *cbk_frame) ret = 0; err: + if (options) + dict_unref(options); if (ret == -1) { if (rpc_clnt) rpc_clnt_unref(rpc_clnt); @@ -2708,8 +2710,13 @@ nlm4svc_init(xlator_t *nfsx) gf_timer_call_after(nfsx->ctx, timeout, nlm_grace_period_over, NULL); nlm4_inited = _gf_true; + + if (options) + dict_unref(options); return &nlm4prog; err: + if (options) + dict_unref(options); return NULL; } -- cgit