]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threads: fix missing unlock in error handling
authorVictor Julien <victor@inliniac.net>
Fri, 16 Jan 2015 10:06:35 +0000 (11:06 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 9 May 2015 09:20:38 +0000 (11:20 +0200)
If TmThreadsUnregisterThread was called with out of range 'id', a lock
would not be cleared after returning from the function.

** CID 1264421:  Missing unlock  (LOCK)
/src/tm-threads.c: 2186 in TmThreadsUnregisterThread()

src/tm-threads.c

index b7fb3a695797c98b31535f99a43436b072ae3492..92f35e5178d845ce1f174a28c554742d521e5dca 100644 (file)
@@ -2112,8 +2112,10 @@ int TmThreadsRegisterThread(ThreadVars *tv, const int type)
 void TmThreadsUnregisterThread(const int id)
 {
     SCMutexLock(&thread_store_lock);
-    if (id <= 0 || id > (int)thread_store.threads_size)
+    if (id <= 0 || id > (int)thread_store.threads_size) {
+        SCMutexUnlock(&thread_store_lock);
         return;
+    }
 
     /* id is one higher than index */
     int idx = id - 1;