Author: glebius
Date: Mon Apr 11 17:23:47 2016
New Revision: 297825
URL: https://svnweb.freebsd.org/changeset/base/297825

Log:
  Merge r285713 (by zec@) from head:
    Prevent null-pointer dereferencing.

Modified:
  stable/10/sys/net/if.c

Modified: stable/10/sys/net/if.c
==============================================================================
--- stable/10/sys/net/if.c      Mon Apr 11 15:24:59 2016        (r297824)
+++ stable/10/sys/net/if.c      Mon Apr 11 17:23:47 2016        (r297825)
@@ -339,11 +339,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);
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to