Skip to content

Commit dcf4291

Browse files
Rex-Chen-NXPaescolar
authored andcommitted
net: lib: dhcpv4: Add check for input parameter of echo_reply_handler
For station and internal AP coexist case, station connected to external AP, ping from station to external AP cause cpu hang. Internal AP dhcpv4 server register handler echo_reply_handler on icmp handler by net_icmp_init_ctx for dhcp server snoop feature. Ping also register handler handle_ipv4_echo_reply on icmp handler for ping cmd. If no external station connect to internal AP, input parameter ‘user_data’ of function echo_reply_handler is NULL. When we trigger ping process, icmp_call_handlers fetch all handlers from icmp handler if receive any ICMP packet, so echo_reply_handler be called, but input parameter is NULL, cause CPU hang. Add input parameters check to fix this issue. Signed-off-by: Rex Chen <[email protected]>
1 parent 0b71206 commit dcf4291

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

subsys/net/lib/dhcpv4/dhcpv4_server.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static int echo_reply_handler(struct net_icmp_ctx *icmp_ctx,
737737
void *user_data)
738738
{
739739
struct dhcpv4_server_ctx *ctx = user_data;
740-
struct dhcpv4_server_probe_ctx *probe_ctx = &ctx->probe_ctx;
740+
struct dhcpv4_server_probe_ctx *probe_ctx;
741741
struct dhcpv4_addr_slot *new_slot = NULL;
742742
struct in_addr peer_addr;
743743

@@ -748,6 +748,12 @@ static int echo_reply_handler(struct net_icmp_ctx *icmp_ctx,
748748

749749
k_mutex_lock(&server_lock, K_FOREVER);
750750

751+
if (ctx == NULL) {
752+
goto out;
753+
}
754+
755+
probe_ctx = &ctx->probe_ctx;
756+
751757
if (probe_ctx->slot == NULL) {
752758
goto out;
753759
}

0 commit comments

Comments
 (0)