From 8da10b943970f6d1b06284ed39ef63e9669dd05e Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Fri, 14 May 2021 14:42:41 +0800 Subject: [PATCH] Fix memory leak check and interity error check. Delete redundant judgments. Close #I3P10Y and #I3QNLT Change-Id: Ibaf5d4da46f12c291619bb88a41ac18af4612ca1 --- kernel/base/mem/membox/los_membox.c | 4 ---- kernel/base/mem/tlsf/los_memory.c | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/kernel/base/mem/membox/los_membox.c b/kernel/base/mem/membox/los_membox.c index fff7e794..cbc48c27 100644 --- a/kernel/base/mem/membox/los_membox.c +++ b/kernel/base/mem/membox/los_membox.c @@ -94,10 +94,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_MemboxInit(VOID *pool, UINT32 poolSize, UINT32 MEMBOX_LOCK(intSave); boxInfo->uwBlkSize = LOS_MEMBOX_ALLIGNED(blkSize + OS_MEMBOX_NODE_HEAD_SIZE); - if (boxInfo->uwBlkSize == 0) { - MEMBOX_UNLOCK(intSave); - return LOS_NOK; - } boxInfo->uwBlkNum = (poolSize - sizeof(LOS_MEMBOX_INFO)) / boxInfo->uwBlkSize; boxInfo->uwBlkCnt = 0; if (boxInfo->uwBlkNum == 0) { diff --git a/kernel/base/mem/tlsf/los_memory.c b/kernel/base/mem/tlsf/los_memory.c index 28e3c418..7db9db96 100644 --- a/kernel/base/mem/tlsf/los_memory.c +++ b/kernel/base/mem/tlsf/los_memory.c @@ -919,10 +919,6 @@ STATIC INLINE VOID *OsMemAlloc(struct OsMemPoolHead *pool, UINT32 size, UINT32 i #endif UINT32 allocSize = OS_MEM_ALIGN(size + OS_MEM_NODE_HEAD_SIZE, OS_MEM_ALIGN_SIZE); - if (allocSize == 0) { - return NULL; - } - #if OS_MEM_EXPAND_ENABLE retry: #endif @@ -1531,13 +1527,13 @@ STATIC INLINE VOID OsMemMagicCheckPrint(struct OsMemNodeHead **tmpNode) STATIC UINT32 OsMemAddrValidCheckPrint(const VOID *pool, struct OsMemFreeNodeHead **tmpNode) { - if (!OsMemAddrValidCheck(pool, (*tmpNode)->prev)) { + if (((*tmpNode)->prev != NULL) && !OsMemAddrValidCheck(pool, (*tmpNode)->prev)) { PRINT_ERR("[%s], %d, memory check error!\n" " freeNode.prev:%#x is out of legal mem range\n", __FUNCTION__, __LINE__, (*tmpNode)->prev); return LOS_NOK; } - if (!OsMemAddrValidCheck(pool, (*tmpNode)->next)) { + if (((*tmpNode)->next != NULL) && !OsMemAddrValidCheck(pool, (*tmpNode)->next)) { PRINT_ERR("[%s], %d, memory check error!\n" " freeNode.next:%#x is out of legal mem range\n", __FUNCTION__, __LINE__, (*tmpNode)->next); -- GitLab