The ifnet pointer (ifp) in rt_newaddrmsg can be valid without ifp->if_addr being set if

if the ifnet is still live by way of a reference but
in line for deletion. Check ifp->if_addr before dereferencing.

Approved by:	sbruno
This commit is contained in:
Matt Macy 2018-05-06 20:32:47 +00:00
parent 86784a0a22
commit 7edd877a1e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333308

View File

@ -1411,7 +1411,10 @@ rt_newmaddrmsg(int cmd, struct ifmultiaddr *ifma)
bzero((caddr_t)&info, sizeof(info));
info.rti_info[RTAX_IFA] = ifma->ifma_addr;
info.rti_info[RTAX_IFP] = ifp ? ifp->if_addr->ifa_addr : NULL;
if (ifp && ifp->if_addr)
info.rti_info[RTAX_IFP] = ifp->if_addr->ifa_addr;
else
info.rti_info[RTAX_IFP] = NULL;
/*
* If a link-layer address is present, present it as a ``gateway''
* (similarly to how ARP entries, e.g., are presented).