mm/mempool: using inline list instead of queue to avoid kasan report

the crash backtrace:
kasan_report (addr=0xf3d02fd4, size=4, is_write=false) at
kasan/kasan.c:106
0x5658518d in __asan_loadN_noabort (addr=0xf3d02fd4, size=4) at
kasan/kasan.c:300
0x565851ee in __asan_load4_noabort (addr=0xf3d02fd4) at
kasan/kasan.c:334
0x56580b02 in sq_remfirst (queue=0xf3d02b08) at
queue/sq_remfirst.c:45
0x565e0e0b in mempool_alloc (pool=0xf3d02aec) at
mempool/mempool.c:161
0x566033d2 in mempool_multiple_alloc (mpool=0xf3d02a30, size=16) at
mempool/mempool_multiple.c:147

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2022-10-30 08:41:08 +08:00
committed by Xiang Xiao
parent 04f15d9dc1
commit adaca6a5ce
2 changed files with 30 additions and 29 deletions
+7 -7
View File
@@ -27,7 +27,7 @@
#include <sys/types.h>
#include <nuttx/queue.h>
#include <nuttx/list.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
@@ -64,12 +64,12 @@ struct mempool_s
/* Private data for memory pool */
sq_queue_t list; /* The free block list in normal mempool */
sq_queue_t ilist; /* The free block list in interrupt mempool */
sq_queue_t elist; /* The expand block list for normal mempool */
size_t nused; /* The number of used block in mempool */
spinlock_t lock; /* The protect lock to mempool */
sem_t waitsem; /* The semaphore of waiter get free block */
struct list_node list; /* The free block list in normal mempool */
struct list_node ilist; /* The free block list in interrupt mempool */
struct list_node elist; /* The expand block list for normal mempool */
size_t nused; /* The number of used block in mempool */
spinlock_t lock; /* The protect lock to mempool */
sem_t waitsem; /* The semaphore of waiter get free block */
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMPOOL)
struct mempool_procfs_entry_s procfs; /* The entry of procfs */
#endif