net: dhcpv4: Fix NULL dereference at dhcpv4_create_message()

Fix dhcpv4_create_message() dereferenced NULL return value from
net_pkt_alloc_with_buffer() in case of no memory available.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
Dmitrii Golovanov 2023-04-26 12:55:43 +02:00 committed by Carles Cufí
parent 1bf036536b
commit 560b777fa8

View file

@ -203,6 +203,9 @@ static struct net_pkt *dhcpv4_create_message(struct net_if *iface, uint8_t type,
pkt = net_pkt_alloc_with_buffer(iface, size, AF_INET,
IPPROTO_UDP, K_FOREVER);
if (!pkt) {
return NULL;
}
net_pkt_set_ipv4_ttl(pkt, 0xFF);