
From: taoqi 30043660 <taoqi10@huawei.com> The system does not check whether the pointer is NULL before releasing the pointer. Signed-off-by: taoqi 30043660 <taoqi10@huawei.com> --- wd_mempool.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wd_mempool.c b/wd_mempool.c index ff9910a..ffb2f47 100644 --- a/wd_mempool.c +++ b/wd_mempool.c @@ -230,8 +230,12 @@ static struct bitmap *create_bitmap(int bits) static void destroy_bitmap(struct bitmap *bm) { - free(bm->map); - free(bm); + if (bm) { + if (bm->map) + free(bm->map); + + free(bm); + } } static unsigned long _find_next_bit(unsigned long *map, unsigned long bits, @@ -893,8 +897,10 @@ static int init_mempool(struct mempool *mp) static void uninit_mempool(struct mempool *mp) { - destroy_bitmap(mp->bitmap); - mp->bitmap = NULL; + if (mp->bitmap) { + destroy_bitmap(mp->bitmap); + mp->bitmap = NULL; + } } handle_t wd_mempool_create(size_t size, int node) -- 2.33.0