[Gluster-devel] [PATCH] timer: fix ctx->timer memleak
qiang.zhang at windriver.com
qiang.zhang at windriver.com
Fri Jul 16 08:12:49 UTC 2021
From: Zqiang <qiang.zhang at windriver.com>
If create timer thread failed, the 'ctx->timer' need
to be released.
Signed-off-by: Zqiang <qiang.zhang at windriver.com>
---
libglusterfs/src/timer.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c
index 66c861b04c..2684d39667 100644
--- a/libglusterfs/src/timer.c
+++ b/libglusterfs/src/timer.c
@@ -213,6 +213,12 @@ gf_timer_registry_init(glusterfs_ctx_t *ctx)
if (ret) {
gf_msg(THIS->name, GF_LOG_ERROR, ret, LG_MSG_PTHREAD_FAILED,
"Thread creation failed");
+ LOCK(&ctx->lock);
+ reg = ctx->timer;
+ ctx->timer = NULL;
+ UNLOCK(&ctx->lock);
+ GF_FREE(reg);
+ reg = NULL;
}
out:
--
2.25.1
More information about the Gluster-devel
mailing list