summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2016-04-11 17:23:47 +0000
committerglebius <glebius@FreeBSD.org>2016-04-11 17:23:47 +0000
commit69db0b60a36e38384e6142004fee3ca428ad98b2 (patch)
treed8be889059713861045d7052723a662599959d1f
parentc7d52025209c6c0c1673d61a541812bd623ad64f (diff)
downloadFreeBSD-src-69db0b60a36e38384e6142004fee3ca428ad98b2.zip
FreeBSD-src-69db0b60a36e38384e6142004fee3ca428ad98b2.tar.gz
Merge r285713 (by zec@) from head:
Prevent null-pointer dereferencing.
-rw-r--r--sys/net/if.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 288d944..af8182b 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -339,11 +339,12 @@ ifnet_setbyindex(u_short idx, struct ifnet *ifp)
struct ifaddr *
ifaddr_byindex(u_short idx)
{
- struct ifaddr *ifa;
+ struct ifnet *ifp;
+ struct ifaddr *ifa = NULL;
IFNET_RLOCK_NOSLEEP();
- ifa = ifnet_byindex_locked(idx)->if_addr;
- if (ifa != NULL)
+ ifp = ifnet_byindex_locked(idx);
+ if (ifp != NULL && (ifa = ifp->if_addr) != NULL)
ifa_ref(ifa);
IFNET_RUNLOCK_NOSLEEP();
return (ifa);
OpenPOWER on IntegriCloud