scope6: Check for NULL afdata before dereferencing

Narrows the race window with if_detach.

Approved by:	mav (mentor)
MFC after:	3 days
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D25017
This commit is contained in:
Ryan Moeller 2020-06-03 16:57:30 +00:00
parent cadd7992e2
commit f057d56c6c

View File

@ -422,6 +422,10 @@ in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
struct epoch_tracker et;
NET_EPOCH_ENTER(et);
if (ifp->if_afinfo[AF_INET6] == NULL) {
NET_EPOCH_EXIT(et);
return (ENETDOWN);
}
sid = SID(ifp);
zoneid = sid->s6id_list[scope];
NET_EPOCH_EXIT(et);