-
Notifications
You must be signed in to change notification settings - Fork 1.1k
backport: "gluterd: fix memory leak in glusterd #4384 " #4466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThalesBarretto
wants to merge
2
commits into
gluster:release-11
Choose a base branch
from
ThalesBarretto:release-11
base: release-11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
CLANG-FORMAT FAILURE: 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 |
mohit84
previously approved these changes
Feb 3, 2025
/run regression |
Backport of 599c608 in branch devel. This part fixes two leaks in posix_cs_set_state. The first is due to the lack of GF_FREE(value) at two paths. The second is due to innapropriate use of dict_set_str_sizen(). Reported-by: chenjinhao <[email protected]> Signed-off-by: Thales Antunes de Oliveira Barretto <[email protected]>
refers to "* glusterd: fix memory leaks due to lack of GF_FREE" This part fixes leaks in glusterd-stored.c and glusterd-utils.c. In the first file it changes at glusterd_store_retrieve_snapd, glusterd_store_retrieve_bricks, glusterd_store_update_volinfo, and glusterd_store_retrieve_peers. In the second file it changes just glusterd_check_and_set_brick_xattr. In glusterd-store.c, there are while loops in gf_store_iter_get_next and also in glusterd_store_retrieve_peers when reaching 'out' there will be memory leak. The memory for 'key' and 'value' will be leaked once gf_store_iter_get_next is called again next loop. In glusterd-utils.c, glusterd_is_path_in_use will be called during volume creation to check brick path reuse. Under normal circumnstances, there is no problem. However, when a `force` cmd is given during volume creation and the futher sys_lsetxattr failed, the memory area previously pointed by *op_errstr will be leaked. Reported-by: chenjinhao <[email protected]> Signed-off-by: Thales Antunes de Oliveira Barretto <[email protected]>
2223adc
to
12f7198
Compare
I did just some formatting to pass clang format, and improved the commit messages. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.