From 407ceeee6d55c8dfd1e7ed469bcb25c358f74d7c Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Fri, 24 Jan 2020 11:41:54 -0800 Subject: [PATCH] net: if: Make sure iface->if_dev is not null when accessing L2 commit 971ae599130d ("net: pkt: Make sure iface is not null when accessing L2") fixed net_if_l2 where iface was NULL, however if iface->if_dev is NULL, the check breaks and returns an offset of NULL (0x82 or so). This is incorrect. Let's add a check for iface->if_dev as well. Signed-off-by: Michael Scott --- include/net/net_if.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/net_if.h b/include/net/net_if.h index 413f7bd8f54..d32c80660c3 100644 --- a/include/net/net_if.h +++ b/include/net/net_if.h @@ -550,7 +550,7 @@ enum net_verdict net_if_send_data(struct net_if *iface, struct net_pkt *pkt); */ static inline const struct net_l2 * const net_if_l2(struct net_if *iface) { - if (!iface) { + if (!iface || !iface->if_dev) { return NULL; }