freebsd-dev/sys
Eric Joyner 566144142e iflib: add iflib_deregister to help cleanup on exit
Commit message by Jake:
The iflib_register function exists to allocate and setup some common
structures used by both iflib_device_register and iflib_pseudo_register.

There is no associated cleanup function used to undo the steps taken in
this function.

Both iflib_device_deregister and iflib_pseudo_deregister have some of
the necessary steps scattered in their flow. However, most of the
necessary cleanup is not done during the error path of
iflib_device_register and iflib_pseudo_register.

Some examples of missed cleanup include:

the ifp pointer is not free'd during error cleanup
the STATE and CTX locks are not destroyed during error cleanup
the vlan event handlers are not removed during error cleanup
media added to the ifmedia structure is not removed
the kobject reference is never deleted
Additionally, when initializing the kobject class reference counter is
increased even though kobj_init already increases it. This results in
the class never being free'd again because the reference count would
never hit zero even after all driver instances are unloaded.

To aid in proper cleanup, implement an iflib_deregister function that
goes through the reverse steps taken by iflib_register.

Call this function during the error cleanup for iflib_device_register
and iflib_pseudo_register. Additionally call the function in the
iflib_device_deregister and iflib_pseudo_deregister functions near the
end of their flow. This helps reduce code duplication and ensures that
proper steps are taken to cleanup allocations and references in both the
regular and error cleanup flows.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Submitted by:	Jacob Keller <jacob.e.keller@intel.com>
Reviewed by:	shurd@, erj@
MFC after:	3 days
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D21005
2019-08-16 23:33:44 +00:00
..
amd64 Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
arm arm64: mv: a37x0_gpio: Set the memory to SHAREABLE 2019-08-16 17:10:38 +00:00
arm64 arm64: Add EspressoBin DTB to the build 2019-08-16 21:11:43 +00:00
bsm
cam Make camcontrol modepage support block descriptors. 2019-08-07 14:45:10 +00:00
cddl Revert r351076 and r351074 because of atomic_swap_64 on 32-bit platforms 2019-08-15 15:27:58 +00:00
compat Implement pci_enable_msi() and pci_disable_msi() in the LinuxKPI. 2019-08-14 09:36:25 +00:00
conf NTB Tool: Test driver for NTB hardware drivers. 2019-08-16 20:14:37 +00:00
contrib MFV: r351091 2019-08-15 17:43:36 +00:00
crypto armv8crypto: add missing unlock for session (after r336439) 2019-08-08 14:34:53 +00:00
ddb Cache kernel stacks in UMA. This gives us NUMA support, better concurrency, 2019-08-06 23:15:34 +00:00
dev NTB Tool: Test driver for NTB hardware drivers. 2019-08-16 20:14:37 +00:00
dts dtso: allwinner: Add an overlay for H3 i2c0 2019-07-20 17:42:46 +00:00
fs fusefs: don't send the namespace during listextattr 2019-08-16 05:06:54 +00:00
gdb
geom geom_uzip(4), mkuzip(8): Add Zstd image mode 2019-08-13 23:32:56 +00:00
gnu arm: dts: am33xx: Fix the region for uart0 2019-08-07 13:11:53 +00:00
i386 Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
isa
kern Add support for 'j', 't' and 'z' flags to kernel sscanf(). 2019-08-16 19:46:22 +00:00
kgssapi Make the warning intervals for deprecated crypto algorithms tunable. 2019-06-11 23:00:55 +00:00
libkern Allow Kernel to link in both legacy libkern/zlib and new sys/contrib/zlib, 2019-08-01 06:35:33 +00:00
mips Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
modules arm64: Add EspressoBin DTB to the build 2019-08-16 21:11:43 +00:00
net iflib: add iflib_deregister to help cleanup on exit 2019-08-16 23:33:44 +00:00
net80211 Enhance the comment ieee80211_add_channel() to avoid a 2019-06-10 14:31:18 +00:00
netgraph Remove 'dir' argument in ng_ipfw_input, since ip_fw_args now has this info. 2019-03-14 22:30:05 +00:00
netinet Save ip_ttl value and restore it after checksum calculation. 2019-08-13 12:47:53 +00:00
netinet6 frag6: move public structure into file local space. 2019-08-08 10:59:54 +00:00
netipsec Add missing new line in several log messages. 2019-08-09 08:58:09 +00:00
netpfil Fix rule truncation on external action module unloading. 2019-08-15 13:44:33 +00:00
netsmb
nfs
nfsclient
nfsserver
nlm
ofed Fix prio vs. nonprio tagged traffic in RDMACM 2019-06-04 06:21:31 +00:00
opencrypto Allow Kernel to link in both legacy libkern/zlib and new sys/contrib/zlib, 2019-08-01 06:35:33 +00:00
powerpc Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
riscv Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
rpc Avoid relying on header pollution from sys/refcount.h. 2019-07-29 20:26:01 +00:00
security Fix mac_veriexec_parser build after r347938 2019-08-08 16:51:49 +00:00
sparc64 Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
sys Delete sys/dir.h which was deprecated since 1997. 2019-08-16 20:53:36 +00:00
teken Attempt to complete fixing programmable function keys for syscons. 2019-02-20 02:14:41 +00:00
tests Regularize the Netflix copyright 2019-02-04 21:28:25 +00:00
tools Add SDIO support. 2019-06-08 16:26:56 +00:00
ufs Clarify comment that describes how the FS_METACKHASH is managed. 2019-08-13 20:56:44 +00:00
vm Check paddr for overflow. 2019-08-16 19:27:05 +00:00
x86 Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
xdr
xen
Makefile