if_ovpn: fix memory leak on unload

When we're unloading the if_ovpn module we sometimes end up only freeing
the softc after the module is unloaded and the M_OVPN malloc type no
longer exists.

Don't return from ovpn_clone_destroy() until the epoch callbacks have
been called, which ensures that we've freed the softc before we destroy
M_OVPN.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
This commit is contained in:
Kristof Provost 2022-09-21 17:23:51 +02:00
parent 9dfbbc919f
commit d99d59a79f

View File

@ -2421,6 +2421,8 @@ ovpn_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
if (unit != IF_DUNIT_NONE)
ifc_free_unit(ifc, unit);
NET_EPOCH_DRAIN_CALLBACKS();
return (0);
}