|
|
c5d8c8 |
From 6d7049a19029331266f70f68d860bbccef01a35d Mon Sep 17 00:00:00 2001
|
|
|
c5d8c8 |
From: Nikhil Ladha <nladha@redhat.com>
|
|
|
c5d8c8 |
Date: Thu, 8 Jul 2021 11:26:54 +0530
|
|
|
c5d8c8 |
Subject: [PATCH 601/610] coverity: resource leak (#2321)
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
Issue:
|
|
|
c5d8c8 |
Variable `arg` is not freed before the function exits,
|
|
|
c5d8c8 |
and leads to resource leak.
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
Fix:
|
|
|
c5d8c8 |
Free the arg variable if the status of function call
|
|
|
c5d8c8 |
`glusterd_compare_friend_volume` is
|
|
|
c5d8c8 |
`GLUSTERD_VOL_COMP_UPDATE_REQ`, or if the `glusterd_launch_synctask`
|
|
|
c5d8c8 |
fails to start the process.
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
And, added a check for return value on calling
|
|
|
c5d8c8 |
`glusterd_launch_synctask` function and exit if the
|
|
|
c5d8c8 |
thread creation fails.
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
CID: 1401716
|
|
|
c5d8c8 |
>Updates: #1060
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
>Change-Id: I4abd621771f88853d8d01e9039cdee2f3d862c4f
|
|
|
c5d8c8 |
>Signed-off-by: nik-redhat <nladha@redhat.com>
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
Upstream link: https://github.com/gluster/glusterfs/pull/2321
|
|
|
c5d8c8 |
BUG: 1997447
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
Change-Id: Ida81dfcd58c5ef45d3ae036d6bd6b36dc6693538
|
|
|
c5d8c8 |
Signed-off-by: nik-redhat <nladha@redhat.com>
|
|
|
c5d8c8 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/280090
|
|
|
c5d8c8 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
c5d8c8 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
c5d8c8 |
---
|
|
|
c5d8c8 |
xlators/mgmt/glusterd/src/glusterd-utils.c | 10 +++++++---
|
|
|
c5d8c8 |
xlators/mgmt/glusterd/src/glusterd-utils.h | 2 +-
|
|
|
c5d8c8 |
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
c5d8c8 |
index c037933..cec9c20 100644
|
|
|
c5d8c8 |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
c5d8c8 |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
c5d8c8 |
@@ -5371,6 +5371,7 @@ glusterd_compare_friend_data(dict_t *peer_data, dict_t *cmp, int32_t *status,
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
if (GLUSTERD_VOL_COMP_RJT == *status) {
|
|
|
c5d8c8 |
ret = 0;
|
|
|
c5d8c8 |
+ update = _gf_false;
|
|
|
c5d8c8 |
goto out;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
if (GLUSTERD_VOL_COMP_UPDATE_REQ == *status) {
|
|
|
c5d8c8 |
@@ -5385,11 +5386,12 @@ glusterd_compare_friend_data(dict_t *peer_data, dict_t *cmp, int32_t *status,
|
|
|
c5d8c8 |
* first brick to come up before attaching the subsequent bricks
|
|
|
c5d8c8 |
* in case brick multiplexing is enabled
|
|
|
c5d8c8 |
*/
|
|
|
c5d8c8 |
- glusterd_launch_synctask(glusterd_import_friend_volumes_synctask, arg);
|
|
|
c5d8c8 |
+ ret = glusterd_launch_synctask(glusterd_import_friend_volumes_synctask,
|
|
|
c5d8c8 |
+ arg);
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
out:
|
|
|
c5d8c8 |
- if (ret && arg) {
|
|
|
c5d8c8 |
+ if ((ret || !update) && arg) {
|
|
|
c5d8c8 |
dict_unref(arg->peer_data);
|
|
|
c5d8c8 |
dict_unref(arg->peer_ver_data);
|
|
|
c5d8c8 |
GF_FREE(arg);
|
|
|
c5d8c8 |
@@ -13115,7 +13117,7 @@ gd_default_synctask_cbk(int ret, call_frame_t *frame, void *opaque)
|
|
|
c5d8c8 |
return ret;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
-void
|
|
|
c5d8c8 |
+int
|
|
|
c5d8c8 |
glusterd_launch_synctask(synctask_fn_t fn, void *opaque)
|
|
|
c5d8c8 |
{
|
|
|
c5d8c8 |
xlator_t *this = NULL;
|
|
|
c5d8c8 |
@@ -13131,6 +13133,8 @@ glusterd_launch_synctask(synctask_fn_t fn, void *opaque)
|
|
|
c5d8c8 |
gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_SPAWN_SVCS_FAIL,
|
|
|
c5d8c8 |
"Failed to spawn bricks"
|
|
|
c5d8c8 |
" and other volume related services");
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ return ret;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
/*
|
|
|
c5d8c8 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
c5d8c8 |
index 4541471..3f4f3b8 100644
|
|
|
c5d8c8 |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
c5d8c8 |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
c5d8c8 |
@@ -681,7 +681,7 @@ int32_t
|
|
|
c5d8c8 |
glusterd_take_lvm_snapshot(glusterd_brickinfo_t *brickinfo,
|
|
|
c5d8c8 |
char *origin_brick_path);
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
-void
|
|
|
c5d8c8 |
+int
|
|
|
c5d8c8 |
glusterd_launch_synctask(synctask_fn_t fn, void *opaque);
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
int
|
|
|
c5d8c8 |
--
|
|
|
c5d8c8 |
1.8.3.1
|
|
|
c5d8c8 |
|