summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzec <zec@FreeBSD.org>2015-07-20 08:21:51 +0000
committerzec <zec@FreeBSD.org>2015-07-20 08:21:51 +0000
commitc8374d535b92af50ae25a95cf5f13e36e2e10a52 (patch)
treeb6699295ec477469dfd16744d55a5680a8ce387d
parent9f9f412505d9bb82d294f7f8d4d6327285488be3 (diff)
downloadFreeBSD-src-c8374d535b92af50ae25a95cf5f13e36e2e10a52.zip
FreeBSD-src-c8374d535b92af50ae25a95cf5f13e36e2e10a52.tar.gz
Prevent null-pointer dereferencing.
MFC after: 3 days
-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 a3e9e3e..6ebfdbf 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -335,11 +335,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