From 3c8572680a3f6a87a634001546bc0b391a1443f9 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 15 Jun 2020 19:34:27 +0900 Subject: [PATCH] tdm_hwc: check hwc_commit_handler's validation before list deleting. Change-Id: Id5c37bc169b0fb982ba1261823333cf8c7587933 Signed-off-by: Junkyeong Kim --- src/tdm_hwc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index 31394a5..5f43860 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -86,6 +86,22 @@ _tdm_hwc_find_private_hwc_window(tdm_private_hwc *private_hwc, tdm_hwc_window *h return NULL; } +static tdm_error +_tdm_hwc_check_hwc_commit_handler_validation(tdm_private_hwc *private_hwc, tdm_private_hwc_commit_handler *hwc_commit_handler) +{ + tdm_private_hwc_commit_handler *commit_handler = NULL; + + if (LIST_IS_EMPTY(&private_hwc->hwc_commit_handler_list)) + return TDM_ERROR_INVALID_PARAMETER; + + LIST_FOR_EACH_ENTRY(commit_handler, &private_hwc->hwc_commit_handler_list, link) { + if (commit_handler == hwc_commit_handler) + return TDM_ERROR_NONE; + } + + return TDM_ERROR_INVALID_PARAMETER; +} + static void _tdm_hwc_thread_cb_commit(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data) @@ -104,6 +120,8 @@ _tdm_hwc_thread_cb_commit(tdm_private_display *private_display, void *object, tdm_thread_cb_remove(private_hwc, TDM_THREAD_CB_HWC_COMMIT, hwc_commit_handler, _tdm_hwc_thread_cb_commit, NULL); + TDM_RETURN_IF_FAIL(_tdm_hwc_check_hwc_commit_handler_validation(private_hwc, hwc_commit_handler) == TDM_ERROR_NONE) + LIST_DEL(&hwc_commit_handler->link); if (tdm_debug_module & TDM_DEBUG_COMMIT) { -- 2.7.4