From 92b94a92d2ab3a0d392c0ba6c412bc20144de956 Mon Sep 17 00:00:00 2001
From: Mohit Agrawal <moagrawa@redhat.com>
Date: Tue, 20 Nov 2018 18:35:58 +0530
Subject: [PATCH 450/450] 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
> (Cherry pick from commit 818e60ac9269c49396480a151c049042af5b2929)
> (Reviewed on link https://review.gluster.org/#/c/glusterfs/+/21630/)
> Change-Id: I4888c071c1058023c7e138a8bcb94ec97305fadf
> fixes: bz#1646892
Change-Id: I9b0a9f4257b74e65c9f8c8686a6b124445f64d64
BUG: 1649651
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/156334
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: RHGS Build Bot <nigelb@redhat.com>
---
xlators/mgmt/glusterd/src/glusterd-handler.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index cab0dec..7486f51 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -6060,6 +6060,7 @@ __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;
brickid = mydata;
if (!brickid)
@@ -6167,8 +6168,11 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata,
*/
GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo,
brickinfo, conf);
- if (!gf_is_service_running (pidfile, &pid) ||
- !search_brick_path_from_proc(pid, brickinfo->path)) {
+ gf_is_service_running(pidfile, &pid);
+ if (pid > 0)
+ brickpath = search_brick_path_from_proc(pid,
+ brickinfo->path);
+ if (!gf_is_service_running (pidfile, &pid) || !brickpath) {
ret = pmap_registry_remove (
THIS, brickinfo->port,
brickinfo->path,
@@ -6186,6 +6190,9 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata,
}
}
+ if (brickpath)
+ GF_FREE (brickpath);
+
if (is_brick_mx_enabled() && glusterd_is_brick_started(brickinfo)) {
brick_proc = brickinfo->brick_proc;
if (!brick_proc)
--
1.8.3.1