From a57cc3207accc7dbca4a5aab9d0de51254c4357b Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 1 Nov 2019 15:48:52 -0400 Subject: [PATCH] libfrog: fix workqueue_add error out Don't forget to unlock before erroring out. Coverity-id: 1454843 Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- libfrog/workqueue.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libfrog/workqueue.c b/libfrog/workqueue.c index 07f11a7b9..a93bba3d3 100644 --- a/libfrog/workqueue.c +++ b/libfrog/workqueue.c @@ -142,8 +142,11 @@ workqueue_add( if (wq->next_item == NULL) { assert(wq->item_count == 0); ret = pthread_cond_signal(&wq->wakeup); - if (ret) - goto out_item; + if (ret) { + pthread_mutex_unlock(&wq->lock); + free(wi); + return ret; + } wq->next_item = wi; } else { wq->last_item->next = wi; @@ -153,9 +156,6 @@ workqueue_add( pthread_mutex_unlock(&wq->lock); return 0; -out_item: - free(wi); - return ret; } /* -- 2.50.1