backport: "gluterd: fix memory leak in glusterd #4384 "
This is a trivial backport of "gluterd: fix memory leak in glusterd #4384"
The main reason for backport is to fix xlators/storage/posix/src/posix-helpers.c by plugging memory leaks in posix_cs_set_state(), which are critical in certain environments.
Backport this so packagers can pick this fix until the release for v12 comes.
Can one of the admins verify this patch?
Can one of the admins verify this patch?
CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format
index e3c02893d..ce3d7a439 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2364,10 +2364,10 @@ glusterd_store_retrieve_snapd(glusterd_volinfo_t *volinfo)
SLEN(GLUSTERD_STORE_KEY_SNAPD_PORT))) {
volinfo->snapd.port = atoi(value);
}
- GF_FREE(key);
- GF_FREE(value);
- key = NULL;
- value = NULL;
+ GF_FREE(key);
+ GF_FREE(value);
+ key = NULL;
+ value = NULL;
ret = gf_store_iter_get_next(iter, &key, &value, &op_errno);
}
@@ -2900,10 +2900,10 @@ glusterd_store_retrieve_bricks(glusterd_volinfo_t *volinfo)
ret = 0;
out:
- if (key)
- GF_FREE(key);
- if (value)
- GF_FREE(value);
+ if (key)
+ GF_FREE(key);
+ if (value)
+ GF_FREE(value);
if (gf_store_iter_destroy(&tmpiter)) {
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_STORE_ITER_DESTROY_FAIL,
"Failed to destroy store iter");
@@ -3049,10 +3049,10 @@ out:
if (dup_value)
GF_FREE(dup_value);
- if (key)
- GF_FREE(key);
- if (value)
- GF_FREE(value);
+ if (key)
+ GF_FREE(key);
+ if (value)
+ GF_FREE(value);
if (ret) {
if (volinfo->rebal.dict)
dict_unref(volinfo->rebal.dict);
@@ -4645,10 +4645,10 @@ glusterd_store_retrieve_peers(xlator_t *this)
peerinfo = glusterd_peerinfo_new(GD_FRIEND_STATE_DEFAULT, NULL, NULL,
0);
if (peerinfo == NULL) {
- GF_FREE(key);
- GF_FREE(value);
- key = NULL;
- value = NULL;
+ GF_FREE(key);
+ GF_FREE(value);
+ key = NULL;
+ value = NULL;
ret = -1;
goto next;
}
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 7fc4058e6..df3ed735a 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -3288,8 +3288,8 @@ posix_cs_set_state(xlator_t *this, dict_t **rsp, gf_cs_obj_state state,
xattrsize = sys_fgetxattr(*fd, GF_CS_OBJECT_REMOTE, value,
xattrsize + 1);
if (xattrsize == -1) {
- if (value)
- GF_FREE(value);
+ if (value)
+ GF_FREE(value);
gf_msg(this->name, GF_LOG_ERROR, 0, errno,
" getxattr failed for key %s", GF_CS_OBJECT_REMOTE);
goto out;
@@ -3313,8 +3313,8 @@ posix_cs_set_state(xlator_t *this, dict_t **rsp, gf_cs_obj_state state,
xattrsize = sys_lgetxattr(path, GF_CS_OBJECT_REMOTE, value,
xattrsize + 1);
if (xattrsize == -1) {
- if (value)
- GF_FREE(value);
+ if (value)
+ GF_FREE(value);
gf_msg(this->name, GF_LOG_ERROR, 0, errno,
" getxattr failed for key %s", GF_CS_OBJECT_REMOTE);
goto out;
@mohit84 do u mind reviewing this one? thanks in advance
/run regression
I did just some formatting to pass clang format, and improved the commit messages.
@ThalesBarretto Is this PR needed for release-11?
@ThalesBarretto Is this PR needed for release-11?
oops, reopening