Skip to content

Commit 32bd3aa

Browse files
rlubosfabiobaltieri
authored andcommitted
net: iface: Allow NULL pointer to be handled in net_if_is_ip_offloaded
In case native interface is used with NET_OFFLOAD enabled, the net_if_is_ip_offloaded() could lead to a crash, if called on unbound net_context (i.e. with no iface assigned to net_context yet). As since commit 40d2240 the net_context allocated on offloaded interface is always assigned with the iface pointer during its creation, it can be safely assumed that in case of NULL pointer is provided we deal with a native interface. Therefore instead of asserting on the iface pointer, indicate that the interface is native when NULL pointer is provided. Signed-off-by: Robert Lubos <[email protected]>
1 parent 90b5554 commit 32bd3aa

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

include/zephyr/net/net_if.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,8 @@ void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt);
756756
static inline bool net_if_is_ip_offloaded(struct net_if *iface)
757757
{
758758
#if defined(CONFIG_NET_OFFLOAD)
759-
NET_ASSERT(iface);
760-
NET_ASSERT(iface->if_dev);
761-
762-
return (iface->if_dev->offload != NULL);
759+
return (iface != NULL && iface->if_dev != NULL &&
760+
iface->if_dev->offload != NULL);
763761
#else
764762
ARG_UNUSED(iface);
765763

0 commit comments

Comments
 (0)