From 2623b7ba5d2bc52640fe875fd8b02ec6c54cf7a2 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 8 May 2023 15:13:49 +0200 Subject: [PATCH] ID Maps are checking whether their pool is locked --- lib/idm.c | 5 +++++ lib/idm.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/idm.c b/lib/idm.c index 66e311c6..ac5ec571 100644 --- a/lib/idm.c +++ b/lib/idm.c @@ -22,6 +22,7 @@ idm_init(struct idm *m, pool *p, uint size) m->used = 1; m->size = size; m->data = mb_allocz(p, m->size * sizeof(u32)); + m->pool = p; /* ID 0 is reserved */ m->data[0] = 1; @@ -34,6 +35,8 @@ idm_alloc(struct idm *m) { uint i, j; + ASSERT_DIE(DG_IS_LOCKED(m->pool->domain)); + for (i = m->pos; i < m->size; i++) if (m->data[i] != 0xffffffff) goto found; @@ -67,6 +70,8 @@ found: void idm_free(struct idm *m, u32 id) { + ASSERT_DIE(DG_IS_LOCKED(m->pool->domain)); + uint i = id / 32; uint j = id % 32; diff --git a/lib/idm.h b/lib/idm.h index e3380cce..69e26ff5 100644 --- a/lib/idm.h +++ b/lib/idm.h @@ -12,6 +12,7 @@ struct idm { + pool *pool; u32 *data; u32 pos; u32 used;