Skip to content

Commit 46662d3

Browse files
Kuen-Han Tsaigregkh
authored andcommitted
Revert "usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device"
This reverts commit 0c09811. This commit is being reverted as part of a series-wide revert. By deferring the net_device allocation to the bind() phase, a single function instance will spawn multiple network devices if it is symlinked to multiple USB configurations. This causes regressions for userspace tools (like the postmarketOS DHCP daemon) that rely on reading the interface name (e.g., "usb0") from configfs. Currently, configfs returns the template "usb%d", causing the userspace network setup to fail. Crucially, because this patch breaks the 1:1 mapping between the function instance and the network device, this naming issue cannot simply be patched. Configfs only exposes a single 'ifname' attribute per instance, making it impossible to accurately report the actual interface name when multiple underlying network devices can exist for that single instance. All configurations tied to the same function instance are meant to share a single network device. Revert this change to restore the 1:1 mapping by allocating the network device at the instance level (alloc_inst). Reported-by: David Heidelberg <david@ixit.cz> Closes: https://lore.kernel.org/linux-usb/70b558ea-a12e-4170-9b8e-c951131249af@ixit.cz/ Fixes: 56a512a ("usb: gadget: f_ncm: align net_device lifecycle with bind/unbind") Cc: stable <stable@kernel.org> Signed-off-by: Kuen-Han Tsai <khtsai@google.com> Link: https://patch.msgid.link/20260309-f-ncm-revert-v2-4-ea2afbc7d9b2@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 37893bc commit 46662d3

2 files changed

Lines changed: 0 additions & 17 deletions

File tree

drivers/usb/gadget/function/u_ether.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,21 +1126,6 @@ void gether_cleanup(struct eth_dev *dev)
11261126
}
11271127
EXPORT_SYMBOL_GPL(gether_cleanup);
11281128

1129-
void gether_unregister_free_netdev(struct net_device *net)
1130-
{
1131-
if (!net)
1132-
return;
1133-
1134-
struct eth_dev *dev = netdev_priv(net);
1135-
1136-
if (net->reg_state == NETREG_REGISTERED) {
1137-
unregister_netdev(net);
1138-
flush_work(&dev->work);
1139-
}
1140-
free_netdev(net);
1141-
}
1142-
EXPORT_SYMBOL_GPL(gether_unregister_free_netdev);
1143-
11441129
/**
11451130
* gether_connect - notify network layer that USB link is active
11461131
* @link: the USB link, set up with endpoints, descriptors matching

drivers/usb/gadget/function/u_ether.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ int gether_get_ifname(struct net_device *net, char *name, int len);
283283
int gether_set_ifname(struct net_device *net, const char *name, int len);
284284

285285
void gether_cleanup(struct eth_dev *dev);
286-
void gether_unregister_free_netdev(struct net_device *net);
287-
DEFINE_FREE(free_gether_netdev, struct net_device *, gether_unregister_free_netdev(_T));
288286

289287
void gether_setup_opts_default(struct gether_opts *opts, const char *name);
290288
void gether_apply_opts(struct net_device *net, struct gether_opts *opts);

0 commit comments

Comments
 (0)