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>
This commit is contained in:
Kinglong Mee 2018-09-18 07:38:48 -04:00
parent 341ba81448
commit 6b273c1644

View File

@ -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
*/