Skip to content

Commit 07c5d2f

Browse files
pabigotjukkar
authored andcommitted
net: dhcp: avoid undefined behavior when assertions disabled
If assertions are disabled the send operation would continue on to transmit a message. Stop it from doing so. Signed-off-by: Peter Bigot <[email protected]>
1 parent 5da984e commit 07c5d2f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

subsys/net/ip/dhcpv4.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static uint32_t dhcpv4_send_request(struct net_if *iface)
305305
const struct in_addr *src_addr = NULL;
306306
bool with_server_id = false;
307307
bool with_requested_ip = false;
308-
struct net_pkt *pkt;
308+
struct net_pkt *pkt = NULL;
309309
uint32_t timeout;
310310

311311
iface->config.dhcpv4.xid++;
@@ -318,6 +318,7 @@ static uint32_t dhcpv4_send_request(struct net_if *iface)
318318
/* Not possible */
319319
NET_ASSERT(0, "Invalid state %s",
320320
net_dhcpv4_state_name(iface->config.dhcpv4.state));
321+
goto fail;
321322
break;
322323
case NET_DHCPV4_REQUESTING:
323324
with_server_id = true;

0 commit comments

Comments
 (0)