1 Star 0 Fork 48

flying-eagle/lwip

forked from src-openEuler/lwip 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0069-add-error-check-in-hugepage_init-and-sys_mbox_free.patch 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
From cbeb07ef6238a719a2bb84837835ebc228ac4fde Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Tue, 20 Jun 2023 14:56:28 +0800
Subject: [PATCH] add error check in hugepage_init and sys_mbox_free
---
src/api/sys_arch.c | 8 ++++++--
src/include/memp_def.h | 13 ++++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/api/sys_arch.c b/src/api/sys_arch.c
index f93a00e..1bc3aee 100644
--- a/src/api/sys_arch.c
+++ b/src/api/sys_arch.c
@@ -124,8 +124,12 @@ err_t sys_mbox_new(struct sys_mbox **mb, int size)
void sys_mbox_free(struct sys_mbox **mb)
{
struct sys_mbox *mbox = *mb;
- rte_ring_free(mbox->ring);
+ if (mbox->ring != NULL) {
+ rte_ring_free(mbox->ring);
+ mbox->ring = NULL;
+ }
memp_free(MEMP_SYS_MBOX, mbox);
+ sys_mbox_set_invalid(mb);
}
err_t sys_mbox_trypost(struct sys_mbox **mb, void *msg)
@@ -371,7 +375,7 @@ uint8_t *sys_hugepage_malloc(const char *name, uint32_t size)
mz = rte_memzone_reserve(name, size, rte_socket_id(), 0);
if (mz == NULL) {
- rte_exit(EXIT_FAILURE, "failed to reserver memory for mempool[%s]\n", name);
+ LWIP_DEBUGF(SYS_DEBUG, ("sys_hugepage_malloc: failed to reserve memory for mempool\n"));
return NULL;
}
diff --git a/src/include/memp_def.h b/src/include/memp_def.h
index 082f685..3408c60 100644
--- a/src/include/memp_def.h
+++ b/src/include/memp_def.h
@@ -52,15 +52,26 @@
#include <lwip/priv/memp_std.h>
#undef LWIP_MEMPOOL
-static inline void hugepage_init(void)
+extern PER_THREAD uint8_t *ram_heap;
+static inline int hugepage_init(void)
{
#define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEMPOOL_BASE_INIT(name)
#include "lwip/priv/memp_std.h"
+ u16_t i;
+ for (i = 0; i < LWIP_ARRAYSIZE(memp_pools); i++) {
+ if (memp_pools[i]->base == NULL) {
+ return -1;
+ }
+ }
#if !MEM_LIBC_MALLOC
LWIP_MEM_MEMORY_DECLARE(ram_heap)
LWIP_MEM_MEMORY_INIT(ram_heap)
+ if (ram_heap == NULL) {
+ return -1;
+ }
#endif /* MEM_LIBC_MALLOC */
+ return 0;
}
#endif /* __MEMP_DEF_H__ */
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flying-eagle12138/lwip.git
git@gitee.com:flying-eagle12138/lwip.git
flying-eagle12138
lwip
lwip
master

搜索帮助