net: fixing a memory leak in if_deregister_com_alloc()
Drain the callbacks upon if_deregister_com_alloc() such that the
if_com_free[type] won't be nullified before if_destroy().
Taking fwip(4) as an example, before this fix, kldunload if_fwip will
go through the following:
- fwip_detach()
- if_free() -> schedule if_destroy() through NET_EPOCH_CALL
- fwip_detach() returns
- firewire_modevent(MOD_UNLOAD) -> if_deregister_com_alloc()
- kernel complains about:
Warning: memory type fw_com leaked memory on destroy (1 allocations, 64 bytes leaked).
- EPOCH runs if_destroy() -> if_free_internal()
By this time, if_com_free[if_alloctype] is NULL since it's already
nullified by if_deregister_com_alloc(); hence, firewire_free() won't
have a chance to release the allocated fw_com.
Reviewed by: hselasky, glebius
MFC after: 2 weeks
(cherry picked from commit 092f3f081265c68cd8de0234ba8e46560ccc061e)