diff options
| author | Kinglong Mee <mijinlong@open-fs.com> | 2018-09-18 07:38:48 -0400 | 
|---|---|---|
| committer | Kinglong Mee <mijinlong@open-fs.com> | 2018-09-26 05:44:34 -0400 | 
| commit | 6b273c1644595472d17f08c891aab62cebecbcbe (patch) | |
| tree | cac505dc2bd2baf8a26821155ea15316af4ea5be | |
| parent | 341ba81448e869ae388b4b37556e47f6bf7413a5 (diff) | |
libgfapi: fix use after freed of clnt when dispatching events
Avoid dispatching events to mgmt after freed,
unreference mgmt after the event_dispatch_destroy.
Change-Id: I5b762b37901de70a955661df0aff95bf055ba4ea
updates: bz#1626313
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
| -rw-r--r-- | api/src/glfs.c | 9 | 
1 files changed, 7 insertions, 2 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c index d21cb8b334f..babaf20cee3 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -1230,8 +1230,6 @@ pub_glfs_fini(struct glfs *fs)      if (ctx->mgmt) {          rpc_clnt_disable(ctx->mgmt); -        rpc_clnt_unref(ctx->mgmt); -        ctx->mgmt = NULL;      }      call_pool = fs->ctx->pool; @@ -1349,6 +1347,13 @@ pub_glfs_fini(struct glfs *fs)              ret = -1;      } +    /* Avoid dispatching events to mgmt after freed, +     * unreference mgmt after the event_dispatch_destroy */ +    if (ctx->mgmt) { +        rpc_clnt_unref(ctx->mgmt); +        ctx->mgmt = NULL; +    } +      /* log infra has to be brought down before destroying       * timer registry, as logging uses timer infra       */  | 
