hyperv/hn: Fix panic in hypervisor code upon device detach event

Submitted by:	hselasky
Reviewed by:	dexuan
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D16139
This commit is contained in:
Dexuan Cui 2018-07-17 21:05:08 +00:00
parent 11df3a2881
commit d76fb49fd8

View File

@ -1161,6 +1161,13 @@ hn_ismyvf(const struct hn_softc *sc, const struct ifnet *ifp)
strcmp(ifp->if_dname, "vlan") == 0)
return (false);
/*
* During detach events ifp->if_addr might be NULL.
* Make sure the bcmp() below doesn't panic on that:
*/
if (ifp->if_addr == NULL || hn_ifp->if_addr == NULL)
return (false);
if (bcmp(IF_LLADDR(ifp), IF_LLADDR(hn_ifp), ETHER_ADDR_LEN) != 0)
return (false);