diff options
author | Mohammed Rafi KC <rkavunga@redhat.com> | 2019-02-26 18:04:18 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-03-20 13:24:44 +0000 |
commit | f2f07591b2de9ba45bbc3eb4f601d1e9a327190b (patch) | |
tree | 1eb628f99b91246759e3bc1e9de1238c9fea2cc4 /glusterfsd/src | |
parent | 6d6a3b298ee81c6c7d93941365852c1bdb42c3c1 (diff) |
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 <rkavunga@redhat.com>
Diffstat (limited to 'glusterfsd/src')
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index a6c3db5b551..15acc109fff 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -2551,7 +2551,11 @@ glusterfs_listener_init(glusterfs_ctx_t *ctx) if (!cmd_args->sock_file) return 0; - ret = rpcsvc_transport_unix_options_build(&options, cmd_args->sock_file); + options = dict_new(); + if (!options) + goto out; + + ret = rpcsvc_transport_unix_options_build(options, cmd_args->sock_file); if (ret) goto out; @@ -2578,6 +2582,8 @@ glusterfs_listener_init(glusterfs_ctx_t *ctx) ctx->listener = rpc; out: + if (options) + dict_unref(options); return ret; } @@ -2659,6 +2665,10 @@ glusterfs_mgmt_init(glusterfs_ctx_t *ctx) if (ctx->mgmt) return 0; + options = dict_new(); + if (!options) + goto out; + LOCK_INIT(&ctx->volfile_lock); if (cmd_args->volfile_server_port) @@ -2668,10 +2678,10 @@ glusterfs_mgmt_init(glusterfs_ctx_t *ctx) if (cmd_args->volfile_server_transport && !strcmp(cmd_args->volfile_server_transport, "unix")) { - ret = rpc_transport_unix_options_build(&options, host, 0); + ret = rpc_transport_unix_options_build(options, host, 0); } else { opt = find_xlator_option_in_cmd_args_t("address-family", cmd_args); - ret = rpc_transport_inet_options_build(&options, host, port, + ret = rpc_transport_inet_options_build(options, host, port, (opt ? opt->value : NULL)); } if (ret) @@ -2720,6 +2730,8 @@ glusterfs_mgmt_init(glusterfs_ctx_t *ctx) ret = rpc_clnt_start(rpc); out: + if (options) + dict_unref(options); return ret; } |