diff options
author | Mohit Agrawal <moagrawal@redhat.com> | 2018-11-13 08:12:06 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-11-16 09:15:37 +0530 |
commit | 818e60ac9269c49396480a151c049042af5b2929 (patch) | |
tree | 58c5cf049d2058056e08f46126ad3e1e3710c8f8 /xlators/mgmt | |
parent | 8204c072ee80c5901ac38e66e346a2ba7da31892 (diff) |
glusterd: fix Resource leak coverity issue
Problem: In commit bcf1e8b07491b48c5372924dbbbad5b8391c6d81 code
was missed to free path return by function search_brick_path_from_proc
This patch fixes CID:
1396668: Resource leak
Change-Id: I4888c071c1058023c7e138a8bcb94ec97305fadf
fixes: bz#1646892
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index ba69a7de7be..1d81d99df1b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -6113,6 +6113,8 @@ __glusterd_brick_rpc_notify(struct rpc_clnt *rpc, void *mydata, glusterd_brickinfo_t *brickinfo_tmp = NULL; glusterd_brick_proc_t *brick_proc = NULL; char pidfile[PATH_MAX] = {0}; + char *brickpath = NULL; + gf_boolean_t is_service_running = _gf_true; brickid = mydata; if (!brickid) @@ -6211,8 +6213,11 @@ __glusterd_brick_rpc_notify(struct rpc_clnt *rpc, void *mydata, * call search_brick_path_from_proc */ GLUSTERD_GET_BRICK_PIDFILE(pidfile, volinfo, brickinfo, conf); - if (!gf_is_service_running(pidfile, &pid) || - !search_brick_path_from_proc(pid, brickinfo->path)) { + is_service_running = gf_is_service_running(pidfile, &pid); + if (pid > 0) + brickpath = search_brick_path_from_proc(pid, + brickinfo->path); + if (!is_service_running || !brickpath) { ret = pmap_registry_remove( THIS, brickinfo->port, brickinfo->path, GF_PMAP_PORT_BRICKSERVER, NULL, _gf_true); @@ -6228,6 +6233,9 @@ __glusterd_brick_rpc_notify(struct rpc_clnt *rpc, void *mydata, } } + if (brickpath) + GF_FREE(brickpath); + if (is_brick_mx_enabled()) { cds_list_for_each_entry(brick_proc, &conf->brick_procs, brick_proc_list) |