summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-handshake.c
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2018-08-21 22:43:22 -0700
committerAmar Tumballi <amarts@redhat.com>2018-08-23 03:44:30 +0000
commit9d2083f2ce37e1f04f5df6040ab493ab98a6f6aa (patch)
tree459f98fe4e814bd552bf6f1d7e6acaaad7e166a4 /xlators/mgmt/glusterd/src/glusterd-handshake.c
parent70181c8b4215e34dfff35fc4918d0e9b5256f32d (diff)
mgmt/glusterd: Fix resource leaks in glusterd-handshake.c
Addresses the following CIDs: 1124768: fd leak in __server_getspec() if spec_fd happens to be 0 1202400: Memory leak in get_snap_volname_and_volinfo() 1214622: Memory leak in glusterd_create_missed_snap() 1214623: Memory leak in an error path of __server_get_volume_info() Change-Id: I33910b4125d25205e76e0d13cf0256d47bd8fc3c updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handshake.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index f2614f4db86..8c109f0f981 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -53,6 +53,7 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
char *vol = NULL;
glusterd_snap_t *snap = NULL;
xlator_t *this = NULL;
+ char *tmp_str_token = NULL;
this = THIS;
GF_ASSERT (this);
@@ -64,6 +65,8 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
goto out;
}
+ tmp_str_token = str_token;
+
/* Input volname will have below formats:
* /snaps/<snapname>/<volname>.<hostname>
* or
@@ -155,6 +158,9 @@ out:
GF_FREE (*volname);
*volname = NULL;
}
+
+ if (tmp_str_token)
+ GF_FREE (tmp_str_token);
return ret;
}
@@ -582,6 +588,7 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
int32_t i = 0;
uuid_t snap_uuid = {0,};
xlator_t *this = NULL;
+ char *mnt_device = NULL;
this = THIS;
GF_ASSERT (this);
@@ -638,8 +645,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
}
/* Fetch the device path */
- device = glusterd_get_brick_mount_device (snap_opinfo->brick_path);
- if (!device) {
+ mnt_device = glusterd_get_brick_mount_device (snap_opinfo->brick_path);
+ if (!mnt_device) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_BRICK_GET_INFO_FAIL,
"Getting device name for the"
@@ -649,7 +656,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
goto out;
}
- device = glusterd_build_snap_device_path (device, snap_vol->volname,
+ device = glusterd_build_snap_device_path (mnt_device,
+ snap_vol->volname,
snap_opinfo->brick_num - 1);
if (!device) {
gf_msg (this->name, GF_LOG_ERROR, ENXIO,
@@ -732,6 +740,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
}
out:
+ if (mnt_device)
+ GF_FREE (mnt_device);
if (device)
GF_FREE (device);
@@ -998,7 +1008,7 @@ __server_getspec (rpcsvc_request_t *req)
/* convert to XDR */
fail:
- if (spec_fd > 0)
+ if (spec_fd >= 0)
sys_close (spec_fd);
GF_FREE(brick_name);
@@ -1491,6 +1501,7 @@ __server_get_volume_info (rpcsvc_request_t *req)
gf_msg ("glusterd", GF_LOG_WARNING, ENOMEM,
GD_MSG_NO_MEMORY, "Out of Memory");
op_errno = ENOMEM;
+ GF_FREE (volume_id_str);
ret = -1;
goto out;
}
@@ -1761,6 +1772,7 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx)
gf_msg (THIS->name, GF_LOG_ERROR, 0,
GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
+ GF_FREE (ctx);
goto unlock;
}
ctx->hostname = gf_strdup (peerinfo->hostname);