]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
host: fix minor coverity warning
authorVictor Julien <vjulien@oisf.net>
Wed, 22 Nov 2023 07:17:45 +0000 (08:17 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 24 Nov 2023 10:57:11 +0000 (11:57 +0100)
CID 1554240:  Data race undermines locking  (LOCK_EVASION)

src/host.c

index 7a5305ac18cc626bacaef3c7514452c1a82f5204..37c0f4dad479582f5c458ce0603e05ec192eaaad 100644 (file)
@@ -340,14 +340,11 @@ void HostShutdown(void)
  */
 void HostCleanup(void)
 {
-    Host *h;
-    uint32_t u;
-
     if (host_hash != NULL) {
-        for (u = 0; u < host_config.hash_size; u++) {
-            h = host_hash[u].head;
+        for (uint32_t u = 0; u < host_config.hash_size; u++) {
             HostHashRow *hb = &host_hash[u];
             HRLOCK_LOCK(hb);
+            Host *h = host_hash[u].head;
             while (h) {
                 if ((SC_ATOMIC_GET(h->use_cnt) > 0) && (h->iprep != NULL)) {
                     /* iprep is attached to host only clear local storage */