[Mesa-dev] [PATCH 3/7] util: slab_destroy_child should check whether it's been initialized

Marek Olšák maraeo at gmail.com
Thu May 25 17:04:43 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/util/slab.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/slab.c b/src/util/slab.c
index 4264814..4ce0e9a 100644
--- a/src/util/slab.c
+++ b/src/util/slab.c
@@ -133,20 +133,23 @@ void slab_create_child(struct slab_child_pool *pool,
 }
 
 /**
  * Destroy the child pool.
  *
  * Pages associated to the pool will be orphaned. They are eventually freed
  * when all objects in them are freed.
  */
 void slab_destroy_child(struct slab_child_pool *pool)
 {
+   if (!pool->parent)
+      return; /* the slab probably wasn't even created */
+
    mtx_lock(&pool->parent->mutex);
 
    while (pool->pages) {
       struct slab_page_header *page = pool->pages;
       pool->pages = page->u.next;
       p_atomic_set(&page->u.num_remaining, pool->parent->num_elements);
 
       for (unsigned i = 0; i < pool->parent->num_elements; ++i) {
          struct slab_element_header *elt = slab_get_element(pool->parent, page, i);
          p_atomic_set(&elt->owner, (intptr_t)page | 1);
-- 
2.7.4



More information about the mesa-dev mailing list