Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Jul 2015 08:21:52 +0000 (UTC)
From:      Marko Zec <zec@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285713 - head/sys/net
Message-ID:  <201507200821.t6K8LqZK046132@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zec
Date: Mon Jul 20 08:21:51 2015
New Revision: 285713
URL: https://svnweb.freebsd.org/changeset/base/285713

Log:
  Prevent null-pointer dereferencing.
  
  MFC after:	3 days

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Mon Jul 20 07:26:31 2015	(r285712)
+++ head/sys/net/if.c	Mon Jul 20 08:21:51 2015	(r285713)
@@ -335,11 +335,12 @@ ifnet_setbyindex(u_short idx, struct ifn
 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507200821.t6K8LqZK046132>