Browse Source

🐞 fix(mempool): fix assert (#8364)

xqyjlj 1 year ago
parent
commit
6be74e227e
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/mempool.c

+ 3 - 1
src/mempool.c

@@ -16,6 +16,7 @@
  * 2012-03-22     Bernard      fix align issue in rt_mp_init and rt_mp_create.
  * 2022-01-07     Gabriel      Moving __on_rt_xxxxx_hook to mempool.c
  * 2023-09-15     xqyjlj       perf rt_hw_interrupt_disable/enable
+ * 2023-12-10     xqyjlj       fix spinlock assert
  */
 
 #include <rthw.h>
@@ -290,12 +291,13 @@ rt_err_t rt_mp_delete(rt_mp_t mp)
         rt_thread_resume(thread);
     }
 
+    rt_spin_unlock_irqrestore(&(mp->spinlock), level);
+
     /* release allocated room */
     rt_free(mp->start_address);
 
     /* detach object */
     rt_object_delete(&(mp->parent));
-    rt_spin_unlock_irqrestore(&(mp->spinlock), level);
 
     return RT_EOK;
 }