Skip to content

Commit 4f171e1

Browse files
[bouffalo lab] fix crash issues in route hook and rpc uart driver mod… (#36944)
* [bouffalo lab] fix crash issues in route hook and rpc uart driver modules * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 96e446d commit 4f171e1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

examples/platform/bouffalolab/bl602/lwipopts/lwipopts.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ a lot of data that needs to be copied, this should be set high. */
6161

6262
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
6363
per active UDP "connection". */
64-
#define MEMP_NUM_UDP_PCB 8
64+
#define MEMP_NUM_UDP_PCB 12
6565

6666
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
6767
connections. */

examples/platform/bouffalolab/common/route_hook/bl_route_hook.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ int8_t bl_route_hook_init(void)
168168
goto exit;
169169
}
170170

171-
for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter++)
171+
for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter = iter->next)
172172
{
173173
if (iter->netif == lwip_netif)
174174
{
175175
ret = 0;
176-
break;
176+
goto exit;
177177
}
178178
}
179179

@@ -194,6 +194,12 @@ int8_t bl_route_hook_init(void)
194194

195195
hook->netif = lwip_netif;
196196
hook->pcb = raw_new_ip_type(IPADDR_TYPE_V6, IP6_NEXTH_ICMP6);
197+
if (NULL == hook->pcb)
198+
{
199+
ret = -1;
200+
goto exit;
201+
}
202+
197203
hook->pcb->flags |= RAW_FLAGS_MULTICAST_LOOP;
198204
hook->pcb->chksum_reqd = 1;
199205
// The ICMPv6 header checksum offset

examples/platform/bouffalolab/common/rpc/pw_sys_io/sys_io.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ Status ReadByte(std::byte * dest)
3131
return Status::InvalidArgument();
3232

3333
int16_t ret = uartRead(reinterpret_cast<char *>(dest), 1);
34-
return ret <= 0 ? Status::FailedPrecondition() : OkStatus();
34+
return ret < 0 ? Status::FailedPrecondition() : OkStatus();
3535
}
3636

3737
Status WriteByte(std::byte b)
3838
{
3939
int16_t ret = uartWrite(reinterpret_cast<const char *>(&b), 1);
4040

41-
return ret <= 0 ? Status::FailedPrecondition() : OkStatus();
41+
return ret < 0 ? Status::FailedPrecondition() : OkStatus();
4242
}
4343

4444
// Writes a string using pw::sys_io, and add newline characters at the end.

0 commit comments

Comments
 (0)