[Gluster-devel] [PATCH] timer: fix ctx->timer memleak

Xavi Hernandez xhernandez at redhat.com
Mon Jul 19 06:35:48 UTC 2021


Thanks for the patch. Could you send it to GitHub so that it can be
reviewed and merged using the regular procedure ?

You can find more information about contributing to the project here:
https://docs.gluster.org/en/latest/Developer-guide/Developers-Index/

Xavi

On Fri, Jul 16, 2021 at 10:43 AM <qiang.zhang at windriver.com> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gluster.org/pipermail/gluster-devel/attachments/20210719/04b65da1/attachment.html>


More information about the Gluster-devel mailing list