Skip to content

Commit 17f852f

Browse files
jukkarfabiobaltieri
authored andcommitted
net: if: ipv6: Do not crash if there are no network interfaces
When trying to get IPv6 prefix, if there are no network interfaces then the net_if_get_default() will return NULL but we should not crash at that point but return gracefully. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent c0b7d8f commit 17f852f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/net/ip/net_if.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,10 @@ struct net_if_ipv6_prefix *net_if_ipv6_prefix_get(struct net_if *iface,
25362536
iface = net_if_get_default();
25372537
}
25382538

2539+
if (!iface) {
2540+
return NULL;
2541+
}
2542+
25392543
net_if_lock(iface);
25402544

25412545
ipv6 = iface->config.ip.ipv6;

0 commit comments

Comments
 (0)