]> git.ipfire.org Git - thirdparty/linux.git/commit
usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device
authorKuen-Han Tsai <khtsai@google.com>
Tue, 30 Dec 2025 10:13:15 +0000 (18:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Jan 2026 15:17:11 +0000 (16:17 +0100)
commit0c0981126b99288ed354d3d414c8a5fd42ac9e25
tree6c25956138aee7a91036539412a5a31569ca7109
parente065c6a7e46c2ee9c677fdbf50035323d2de1215
usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device

The net_device in the u_ether framework currently requires explicit
calls to unregister and free the device.

Introduce gether_unregister_free_netdev() and the corresponding
auto-cleanup macro. This ensures that if a net_device is registered, it
is properly unregistered and the associated work queue is flushed before
the memory is freed.

This is a preparatory patch to simplify error handling paths in gadget
drivers by removing the need for explicit goto labels for net_device
cleanup.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Link: https://patch.msgid.link/20251230-ncm-refactor-v1-2-793e347bc7a7@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/u_ether.c
drivers/usb/gadget/function/u_ether.h