Add mtx_enter/mtx_leave in kvp_pool_keys().
authorasou <asou@openbsd.org>
Mon, 26 Jul 2021 06:00:37 +0000 (06:00 +0000)
committerasou <asou@openbsd.org>
Mon, 26 Jul 2021 06:00:37 +0000 (06:00 +0000)
ok mikeb

sys/dev/pv/hypervic.c

index ef96dce..ad5fc9b 100644 (file)
@@ -759,14 +759,21 @@ kvp_pool_keys(struct kvp_pool *kvpl, int next, char *key, size_t *keylen)
        struct kvp_entry *kpe;
        int iter = 0;
 
+       mtx_enter(&kvpl->kvp_lock);
+
        TAILQ_FOREACH(kpe, &kvpl->kvp_entries, kpe_entry) {
                if (iter++ < next)
                        continue;
                *keylen = strlen(kpe->kpe_key) + 1;
                strlcpy(key, kpe->kpe_key, *keylen);
+
+               mtx_leave(&kvpl->kvp_lock);
+
                return (0);
        }
 
+       mtx_leave(&kvpl->kvp_lock);
+
        return (-1);
 }