From: SooChan Lim Date: Thu, 24 Jun 2021 03:01:12 +0000 (+0900) Subject: tbm_bufmgr: lock the gLock before locking tbm_bufmgr_mutex X-Git-Tag: accepted/tizen/unified/20210625.170433~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Flibtbm.git;a=commitdiff_plain;h=238437409d604e27c1dd8162578e4c4a9fa5acae;hp=dfd39529977c7b91df149c4ed953c64e3e93ad2c tbm_bufmgr: lock the gLock before locking tbm_bufmgr_mutex The order of locking mutex makes deadlock. So this patch will start to fix. Change-Id: Ic7b866eb5b6826239e1b671c059d0393c47ac4f1 --- diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 6457f16..55f9243 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -364,22 +364,22 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr) { TBM_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr)); - _tbm_bufmgr_mutex_lock(); pthread_mutex_lock(&gLock); + _tbm_bufmgr_mutex_lock(); _tbm_set_last_result(TBM_ERROR_NONE); if (!gBufMgr) { TBM_ERR("gBufmgr already destroy: bufmgr:%p\n", bufmgr); - pthread_mutex_unlock(&gLock); _tbm_bufmgr_mutex_unlock(); + pthread_mutex_unlock(&gLock); return; } bufmgr->ref_count--; if (bufmgr->ref_count > 0) { TBM_DBG("reduce a ref_count(%d) of tbm_bufmgr(%p)\n", bufmgr->ref_count, bufmgr); - pthread_mutex_unlock(&gLock); _tbm_bufmgr_mutex_unlock(); + pthread_mutex_unlock(&gLock); return; } @@ -415,8 +415,8 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr) free(bufmgr); gBufMgr = NULL; - pthread_mutex_unlock(&gLock); _tbm_bufmgr_mutex_unlock(); + pthread_mutex_unlock(&gLock); } unsigned int