fix use after free when releasing a netmap adapter.

Submitted by:	Giuseppe Lettieri
This commit is contained in:
Luigi Rizzo 2014-01-07 21:14:28 +00:00
parent 88c4b8d145
commit fb25194fb0
2 changed files with 10 additions and 5 deletions

View file

@ -2208,9 +2208,14 @@ netmap_detach(struct ifnet *ifp)
NMG_LOCK();
netmap_disable_all_rings(ifp);
netmap_adapter_put(na);
na->ifp = NULL;
netmap_enable_all_rings(ifp);
if (!netmap_adapter_put(na)) {
/* someone is still using the adapter,
* tell them that the interface is gone
*/
na->ifp = NULL;
/* give them a chance to notice */
netmap_enable_all_rings(ifp);
}
NMG_UNLOCK();
}

View file

@ -899,11 +899,11 @@ void __netmap_adapter_get(struct netmap_adapter *na);
int __netmap_adapter_put(struct netmap_adapter *na);
#define netmap_adapter_put(na) \
do { \
({ \
struct netmap_adapter *__na = na; \
D("putting %p:%s (%d)", __na, NM_IFPNAME(__na->ifp), __na->na_refcount); \
__netmap_adapter_put(__na); \
} while (0)
})
#else /* !NM_DEBUG_PUTGET */