!443 add error check in hugepage_init and sys_mbox_free

From: @jiangheng12 
Reviewed-by: @LemmyHuang 
Signed-off-by: @LemmyHuang
This commit is contained in:
openeuler-ci-bot 2023-06-26 07:21:13 +00:00 committed by Gitee
commit 876118c228
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,72 @@
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;
+ if (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

View File

@ -4,7 +4,7 @@
Summary: lwip is a small independent implementation of the TCP/IP protocol suite
Name: lwip
Version: 2.1.3
Release: 73
Release: 74
License: BSD
URL: http://savannah.nongnu.org/projects/lwip/
Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip
@ -80,6 +80,7 @@ Patch9064: 0065-fix-udp-recvmbox-size-not-set.patch
Patch9065: 0066-adapt-to-dpdk-19.11-and-dpdk-21.11.patch
Patch9066: 0067-fix-null-pointer-when-all-zero-address-listen.patch
Patch9067: 0068-enable-UDP-CKSUM-in-lwip.patch
Patch9068: 0069-add-error-check-in-hugepage_init-and-sys_mbox_free.patch
BuildRequires: gcc-c++ dos2unix dpdk-devel
@ -110,6 +111,9 @@ cd %{_builddir}/%{name}-%{version}/src
%{_libdir}/liblwip.a
%changelog
* Sun Jun 25 2023 jiangheng <jiangheng14@huawei.com> - 2.1.3-74
- add error check in hugepage_init and sys_mbox_free
* Wed Jun 21 2023 kircher <majun65@huawei.com> - 2.1.3-73
- enable udp cksum in lwip