From 4f171e15b1aed50c190feb061597e531a956e751 Mon Sep 17 00:00:00 2001 From: wyhong <30567533+wy-hh@users.noreply.github.com> Date: Tue, 7 Jan 2025 21:56:02 +0800 Subject: [PATCH] =?UTF-8?q?[bouffalo=20lab]=20fix=20crash=20issues=20in=20?= =?UTF-8?q?route=20hook=20and=20rpc=20uart=20driver=20mod=E2=80=A6=20(#369?= =?UTF-8?q?44)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [bouffalo lab] fix crash issues in route hook and rpc uart driver modules * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .../platform/bouffalolab/bl602/lwipopts/lwipopts.h | 2 +- .../bouffalolab/common/route_hook/bl_route_hook.c | 10 ++++++++-- .../bouffalolab/common/rpc/pw_sys_io/sys_io.cc | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/platform/bouffalolab/bl602/lwipopts/lwipopts.h b/examples/platform/bouffalolab/bl602/lwipopts/lwipopts.h index ba744a119d77e3..93c14da58cfbbb 100644 --- a/examples/platform/bouffalolab/bl602/lwipopts/lwipopts.h +++ b/examples/platform/bouffalolab/bl602/lwipopts/lwipopts.h @@ -61,7 +61,7 @@ a lot of data that needs to be copied, this should be set high. */ /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */ -#define MEMP_NUM_UDP_PCB 8 +#define MEMP_NUM_UDP_PCB 12 /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. */ diff --git a/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c b/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c index 0da6d1bfb34383..f9f35ba8d5da26 100644 --- a/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c +++ b/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c @@ -168,12 +168,12 @@ int8_t bl_route_hook_init(void) goto exit; } - for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter++) + for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter = iter->next) { if (iter->netif == lwip_netif) { ret = 0; - break; + goto exit; } } @@ -194,6 +194,12 @@ int8_t bl_route_hook_init(void) hook->netif = lwip_netif; hook->pcb = raw_new_ip_type(IPADDR_TYPE_V6, IP6_NEXTH_ICMP6); + if (NULL == hook->pcb) + { + ret = -1; + goto exit; + } + hook->pcb->flags |= RAW_FLAGS_MULTICAST_LOOP; hook->pcb->chksum_reqd = 1; // The ICMPv6 header checksum offset diff --git a/examples/platform/bouffalolab/common/rpc/pw_sys_io/sys_io.cc b/examples/platform/bouffalolab/common/rpc/pw_sys_io/sys_io.cc index b7212e48ad8a5f..a2c847f7ce9c96 100644 --- a/examples/platform/bouffalolab/common/rpc/pw_sys_io/sys_io.cc +++ b/examples/platform/bouffalolab/common/rpc/pw_sys_io/sys_io.cc @@ -31,14 +31,14 @@ Status ReadByte(std::byte * dest) return Status::InvalidArgument(); int16_t ret = uartRead(reinterpret_cast(dest), 1); - return ret <= 0 ? Status::FailedPrecondition() : OkStatus(); + return ret < 0 ? Status::FailedPrecondition() : OkStatus(); } Status WriteByte(std::byte b) { int16_t ret = uartWrite(reinterpret_cast(&b), 1); - return ret <= 0 ? Status::FailedPrecondition() : OkStatus(); + return ret < 0 ? Status::FailedPrecondition() : OkStatus(); } // Writes a string using pw::sys_io, and add newline characters at the end.