From nobody Thu Apr 9 12:50:24 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A19513A4F2C for ; Mon, 9 Mar 2026 12:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773057925; cv=none; b=kC+tkgCP6XacVCxvK9oHbmj33M9ptcXfEea4dhdcUFn92OmWgGQkZzElx4rF4e8Z6+iXJ7wTXEp/IqhQeCG+pQD+h8BQqmvXePFVV7KpaPOXozn/3aMJaKTsCXctRfHD1qUx4FSeYppjPRlkUJj1cPDfNetoeaW1ZHGffKu/9cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773057925; c=relaxed/simple; bh=CGO0VfQC6nWNWzuPE6zNy8nqRc46IAy8DWObfpSsHuI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VRB4zWZk1TRnpECK0tFJh/3c/wvVEKsASARi9b+ENCYbDvSX0BO367UdFtYpYY6LgcCcN28tAN6iB31ZpBOKyo4A//XFrgW2sLWnFfb+siaikMgJTo31zb9xwDgMbIZT5SIZLRQOcnjGmCtFv8FFBMMSVBRcm2uscE8O/sEUB/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--khtsai.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=u4isXG5Z; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--khtsai.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u4isXG5Z" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2ae47b3adacso77146805ad.3 for ; Mon, 09 Mar 2026 05:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773057924; x=1773662724; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QMXsEKlWRclFBEv0xYibqErY/p3FsrhNFarJ+RqhwzI=; b=u4isXG5Ze6QNNq4KCvsy+FSloKVpNVB/n8TUHRQZAbLcdt+6alphdR0+7TOqOhB0BQ 0cn82h22dWUfcaWnzp3Ivn/CPGnHmUxffucpGq7KK5+gZzS0cplluFroTOD9q7z6E/f1 cz4Qo9fohpWmPsupU589OLE28fFIZylaPu0X+qVfOV/ePJNp6MWVpzwZ/0deAbJQpnrS GPA/bweU30WOJMGlAJU5f+x/aoyOMRHb1KTjFjMcpZi9DSmiz5IB86fT2zFNh8mD8B4R iGfaVng066TiPMrjJAujqeTOMsjzJeryKgkqYKPYdx4o55rVT8tw8c7SfPV6/a2OkBuk JVOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773057924; x=1773662724; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QMXsEKlWRclFBEv0xYibqErY/p3FsrhNFarJ+RqhwzI=; b=CwXdeH/1JOx+vSt+jTfeAXLEwtTgRcH86vmBUUJNePePXW72gMngHEVHS88BhN8rH/ le+OR4YXlDM3kSS4/JXnB25Z5qHvgkMOVoxm64FFadCl+WZbFg696e4a6owe8hUevEYk 9e5luAyV2M/IKAdvRKxgRxaj3hJCdgGIzDRpxiB9PiHubPV0hLLfx+vKaTLrr65qIV3s SVcgRo4lYzhs525op4j81E0gQ/RbErq96btXfJnfH+eBx1d2OSI6wG07mEULi25po3kj OUVqphocKp85ePEvxeBKo7/nZjUnk1SwuTppk7Ksy3DvOMYgEVBWywNg0PwIjxhR8oZE viyw== X-Forwarded-Encrypted: i=1; AJvYcCU98c7YCwO53PJvN0Ug3RzNSAr4cPNfAucDyhE+lSDYV7rXesMXpNspjg9OEFU2ER9l/QFvOd4KnpJFRTc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywj1QokCvA2DmqQlAJdKOOmelEBEbW/CKj25eIJSmmmd4UQeIQ7 M8O7L3plmFaiWq3qQQN0ZFlQ6vPl+DbPZ/TkbnNJaQ3p05L6WQEaXzy5QXwsGRy3KIR6P10cHTe cAzSFEA== X-Received: from ploh7.prod.google.com ([2002:a17:902:f707:b0:2ae:69d3:5b9d]) (user=khtsai job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f70f:b0:2ae:4409:5993 with SMTP id d9443c01a7336-2ae82566029mr113712635ad.55.1773057923863; Mon, 09 Mar 2026 05:05:23 -0700 (PDT) Date: Mon, 09 Mar 2026 20:04:49 +0800 In-Reply-To: <20260309-f-ncm-revert-v2-0-ea2afbc7d9b2@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260309-f-ncm-revert-v2-0-ea2afbc7d9b2@google.com> X-Developer-Key: i=khtsai@google.com; a=ed25519; pk=abA4Pw6dY2ZufSbSXW9mtp7xiv1AVPtgRhCFWJSEqLE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1773057914; l=3155; i=khtsai@google.com; s=20250916; h=from:subject:message-id; bh=CGO0VfQC6nWNWzuPE6zNy8nqRc46IAy8DWObfpSsHuI=; b=/M9ZIevcQVfuTs7LJ/pfq4hvrqTG4FI4H71uy/WOxzWy2i1cI8s+nYuaWQf7oRmEINKFx0aDn Cbcx3+38AEODyn3K85GlNH10cLMepyezAH4S45tCesESKniS2fgXN1N X-Mailer: b4 0.14.3 Message-ID: <20260309-f-ncm-revert-v2-4-ea2afbc7d9b2@google.com> Subject: [PATCH v2 4/7] Revert "usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device" From: Kuen-Han Tsai To: Greg Kroah-Hartman , Felipe Balbi , Kyungmin Park Cc: David Heidelberg , Ernest Van Hoecke , Jon Hunter , LI Qingwu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kuen-Han Tsai Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This reverts commit 0c0981126b99288ed354d3d414c8a5fd42ac9e25. 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 Closes: https://lore.kernel.org/linux-usb/70b558ea-a12e-4170-9b8e-c95113124= 9af@ixit.cz/ Fixes: 56a512a9b410 ("usb: gadget: f_ncm: align net_device lifecycle with b= ind/unbind") Signed-off-by: Kuen-Han Tsai --- drivers/usb/gadget/function/u_ether.c | 15 --------------- drivers/usb/gadget/function/u_ether.h | 2 -- 2 files changed, 17 deletions(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/fun= ction/u_ether.c index 338f6e2a85a9..15685b2f8887 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -1126,21 +1126,6 @@ void gether_cleanup(struct eth_dev *dev) } EXPORT_SYMBOL_GPL(gether_cleanup); =20 -void gether_unregister_free_netdev(struct net_device *net) -{ - if (!net) - return; - - struct eth_dev *dev =3D netdev_priv(net); - - if (net->reg_state =3D=3D NETREG_REGISTERED) { - unregister_netdev(net); - flush_work(&dev->work); - } - free_netdev(net); -} -EXPORT_SYMBOL_GPL(gether_unregister_free_netdev); - /** * gether_connect - notify network layer that USB link is active * @link: the USB link, set up with endpoints, descriptors matching diff --git a/drivers/usb/gadget/function/u_ether.h b/drivers/usb/gadget/fun= ction/u_ether.h index a212a8ec5eb1..63a0240df4d7 100644 --- a/drivers/usb/gadget/function/u_ether.h +++ b/drivers/usb/gadget/function/u_ether.h @@ -283,8 +283,6 @@ int gether_get_ifname(struct net_device *net, char *nam= e, int len); int gether_set_ifname(struct net_device *net, const char *name, int len); =20 void gether_cleanup(struct eth_dev *dev); -void gether_unregister_free_netdev(struct net_device *net); -DEFINE_FREE(free_gether_netdev, struct net_device *, gether_unregister_fre= e_netdev(_T)); =20 void gether_setup_opts_default(struct gether_opts *opts, const char *name); void gether_apply_opts(struct net_device *net, struct gether_opts *opts); --=20 2.53.0.473.g4a7958ca14-goog