Don't call enable_all_rings if the adapter has been freed.

This is a subtle use-after-free race that results in some very undesirable
hang behaviour.

Reviewed by:	pkelsey
Obtained from:	Kip Macy, NextBSD (91a9bd1dbb)
This commit is contained in:
Adrian Chadd 2015-09-07 23:16:39 +00:00
parent c80b6ca937
commit 15b1492c9b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287543

View File

@ -2841,10 +2841,12 @@ void
netmap_detach(struct ifnet *ifp)
{
struct netmap_adapter *na = NA(ifp);
int skip;
if (!na)
return;
skip = 0;
NMG_LOCK();
netmap_disable_all_rings(ifp);
na->ifp = NULL;
@ -2856,10 +2858,11 @@ netmap_detach(struct ifnet *ifp)
* the driver is gone.
*/
if (na->na_flags & NAF_NATIVE) {
netmap_adapter_put(na);
skip = netmap_adapter_put(na);
}
/* give them a chance to notice */
netmap_enable_all_rings(ifp);
if (skip == 0)
netmap_enable_all_rings(ifp);
NMG_UNLOCK();
}