diff --git a/net/route/net_alloc_ramroute.c b/net/route/net_alloc_ramroute.c index 85d8127574..17d60f7f03 100644 --- a/net/route/net_alloc_ramroute.c +++ b/net/route/net_alloc_ramroute.c @@ -159,6 +159,11 @@ FAR struct net_route_ipv4_s *net_allocroute_ipv4(void) route = ramroute_ipv4_remfirst(&g_free_ipv4routes); net_unlock(); + if (!route) + { + return NULL; + } + return &route->entry; } #endif @@ -177,6 +182,11 @@ FAR struct net_route_ipv6_s *net_allocroute_ipv6(void) route = ramroute_ipv6_remfirst(&g_free_ipv6routes); net_unlock(); + if (!route) + { + return NULL; + } + return &route->entry; } #endif