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:
parent
c80b6ca937
commit
15b1492c9b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287543
@ -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,9 +2858,10 @@ 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 */
|
||||
if (skip == 0)
|
||||
netmap_enable_all_rings(ifp);
|
||||
NMG_UNLOCK();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user