Skip to content

Commit

Permalink
Prevent null-pointer dereferencing.
Browse files Browse the repository at this point in the history
MFC after:	3 days
  • Loading branch information
gornjas committed Jul 20, 2015
1 parent af9aa0a commit 22a9384
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sys/net/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 22a9384

Please sign in to comment.