Article View: linux.kernel.netdev
Article #25137Re: [PATCH net-next 1/9] can: gs_usb: gs_usb_probe(): init netdev completely before register_candev()
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 09:41
Date: Tue, 01 Dec 2026 09:41
93 lines
11213 bytes
11213 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] This patch moves register_candev() out of gs_make_candev()
into a second loop in gs_usb_probe().
--
can: gs_usb: gs_usb_probe(): init netdev completely before register_candev()
This patch takes register_candev() out of gs_make_candev(). The probe
routine now allocates and fully initializes every CAN channel first, then
registers them all in a second loop. unregister_candev() moves out of
gs_destroy_candev() into gs_usb_disconnect() and the probe error paths.
Link: https://patch.msgid.link/20261130-gs_usb-fixes-v12-1-9ba1f84c179a@pengutronix.de
> diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
> index 15f28833f2deb..965151ab50a1e 100644
> --- a/drivers/net/can/usb/gs_usb.c
> +++ b/drivers/net/can/usb/gs_usb.c
[ ... ]
> @@ -1621,7 +1605,37 @@ static int gs_usb_probe(struct usb_interface *intf,
> parent->hf_size_rx = max(parent->hf_size_rx, hf_size_rx);
> }
>
> + for (i = 0; i < icount; i++) {
> + struct gs_can *dev = parent->canch[i];
> +
> + rc = register_candev(dev->netdev);
[Severity: Medium]
With this ordering, every parent->canch[i] is non-NULL before any channel
is registered. Once register_candev() returns for channel 0, userspace can
open can0 while canch[1..n] are still unregistered.
Opening the first channel submits all of the shared bulk-IN URBs:
gs_can_open() {
...
if (!parent->active_channels) {
...
for (i = 0; i < GS_MAX_RX_URBS; i++) {
...
}
Suppose the device sends a frame for a channel that is not registered yet,
inside this window. What happens in gs_usb_receive_bulk_callback()?
dev = parent->canch[hf->channel];
netdev = dev->netdev;
stats = &netdev->stats;
if (!netif_device_present(netdev))
return;
Only register_netdevice() sets __LINK_STATE_PRESENT, so the unregistered
netdev looks detached. The bare return skips the resubmit_urb label. USB
core has already unanchored the URB, so it is never resubmitted.
Could each such frame permanently remove one URB from the shared RX pool?
If enough of them arrive, would reception stop on all channels until every
channel is closed and reopened?
The window covers the rest of gs_can_open(), including its control
transfers, which run under RTNL. register_candev() for the next channel
also has to wait for RTNL.
Triggering this needs a device that sends frames for a channel the host has
not started. One example is firmware that keeps channel state across
re-enumeration, because probe does not reset the channels.
Before this patch the same input would dereference a NULL canch[1], so this
is an improvement. However, the RX path now treats the new "allocated but
not yet registered" state as a detached device.
The early return in gs_usb_receive_bulk_callback() is still unchanged at the
end of the series (6f2e6f8d658b).
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130092003.1946901-2-mkl%40pengutronix.de
Technical Details
Message-ID:
<179611808903.3146.10926780520247936704@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374908-linux-kernel-netdev=dewy.ruReferences:
<20261130092003.1946901-2-mkl@pengutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374908-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 1/9] can: gs_usb: gs_usb_probe(): init netdev completely before register_candev() Date: Tue, 01 Dec 2026 09:41:29 +0000 Organization: Usenet Network Message-ID: <179611808903.3146.10926780520247936704@kernel.org> References: <20261130092003.1946901-2-mkl@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1676028"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:69L3i1nPF6fROj2KjFZ9XZQTH4Y= sha256:SFilSR2YrKr+Tv7LoCOq1XP9ZuiKBTXI1WGlgUdLmUk= sha1:VEaVN42n9MVnqelVuMMpME7TK3Y= sha256:7MCfjbds8cA93ojaCC5RSwXHdt94c2q5WoToBJBKtVY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 9A3A9117307; Tue, 1 Dec 2026 12:41:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3EO8d66ZiElC; Tue, 1 Dec 2026 12:41:52 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374908-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id D1904117308; Tue, 1 Dec 2026 12:41:43 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 59E5333098; Tue, 1 Dec 2026 09:41:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796118096; b=T1lGbgBNjQXtOTOBZ4UleBo2A0Sc0h4VIOiTtbvApe/rpQl2YSTG3D7COQBmyOS9KxHq UbJlhAa1iwGkpHXPNjRQ7KK+K6ZhmuUyRY3c0BDMYV1MhUUrAxz9K1SunZ1y2g2+nuYO9 HHXlDboA3TnWPdOettAQjhYPQlaH7avDODxSrzPOw+S1br1jMuWr5KwXhMbmxV/Qxsszf FlTWTKxYjIN/sJBcBvSIm9K+UNe0ruK2OXJZdUy76yi8LQ2zltRDEE23A9H1WNg7l/uOC fp83V0Ws6wUgyLTbP5Uqonpk+mCo6X0/JPeXT7Y8n1ruHRXhBtQ45TgN2RCQeTusbKQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796118096; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=m+ByIoe6KfgvyeOQ6vsMIjcwx5eP6S2jL/FSUnWKRbI=; b=SyQOq5nRALxgNYAOctQbe7metxypsOS+5Fy+CC+3ou4HLOFLlgfrH/RQk8fBn8/I9kHb nTMP1bo0vrESSejX3R8K7gCHQe55sJnvPNd6Tl460RPnC01htVPOFhWNZoB8E4w73Wyos dbguMs+r/vrNZKI2oU9YQICbLDDWha6ZproQ8rb2+w0+TC7mW/CdMIuBslbIL4nDcoM8K SPEo3PT+EEr5Oinfl49DwMt0VEUkb1glTpgMoHXkrgPlAi/r1373/OEBGizzFfRD0tB8z JXu86uwltqtAQ4Oi+11LGGWbKSw104pr7Q8HMiTcaQ+Os7gyH8P4nCl6Kj4G/GjXXNw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MbUidU65; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31C15606A32E; Tue, 1 Dec 2026 09:41:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MbUidU65 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796118090; b=HzO1MNju++NAYMmqKP+Fb2UITB3MbedpFn/Cjeye3IjZumHAnZQTR2q+0njjN+HxqV+q 8wPOAkKMsYYc5wPtUbWqiIoxH+/gqEmYTI7MEe4rNxn3uCYG8WXD5rLyRKiw6uGblLNK4 WmxWG+TlD9uOYPBZSk3P+yKsPblkb+w790Q0QlF6NFvxynx9gUhEzhEFQWIF6+neS7y2x 88wizBzPEntlHVmk6dtLdiQKll1sPcuCsRqk8h/gbgYr0sN2qH6A7mzyn+PC8PPTQZWqV p/jp1KHGBp+3C7GGEHBr7vMsWjnhxzVGlOkcdAHxIwAVTRwDwPx1O25VZUWzTA/a4Qw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796118090; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=m+ByIoe6KfgvyeOQ6vsMIjcwx5eP6S2jL/FSUnWKRbI=; b=Bd8iJrKWAr55LwFUequeQ1r4Xsmg9lFni1P+a9sznRNLPOdceQ0Q7XssmT3TZUFn4WyA dqV7q6ErFDhhJqpOOrAGHbrAxvz3w0m8sdrR5hZJwKHEiKI9jMfH86pc9gPWkh17XD9I3 9w0i3svSZLpVlGR1CR7QeSRuhKa2WWFEw4eumJ3sgZKi+bSwXW3H2qyhiyr3ifY80BboW /mrPYSeUviJL4G/u/JpYOmektpW/l1BFrE9GR2fHOgt7OPLrZTtLhULmbmTKJqt+6hyYO NNkhHcV0oCqrqTa53qb/3zu2NZMv2/TlxvFu9rLun8Hkuo5yMFErAeo2NUKTSXcFcvw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MbUidU65; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F089606A329; Tue, 1 Dec 2026 09:41:30 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 829231F000C1; Tue, 1 Dec 2026 09:41:29 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796118090; bh=m+ByIoe6KfgvyeOQ6vsMIjcwx5eP6S2jL/FSUnWKRbI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=MbUidU654RViuER1xX9XZNwHOGFBf7qaP+gHvjXVBNDaOCjSGOhIrNyMesqFxJhD0 wrMx/KxR76qLoTcJfN+t7hmpm3+TCx+iFhJdkUKWBkGazut2t0sDrk64pNqrvDXNKI ZNnORRRQZRGRb1mXP1O7ivZYx/d4sM2aP1nHtclV5OdL/XXeGrETQ0dUhHF0Wneilp hN2wYQ3wKAZWqt510UZ5UeootqsxEIaWJZkqLd97JRx3tVJNyyFm4jhNNyWgF7UEIO KC680nkYlJCsyEUu5k1QfFpRR4IC5J5e4W8e6B0oJwgsy07Huj6CdQrbQALLxsfsav fKERvpMf60vdA== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, shuangpeng.kernel@gmail.com, stable@vger.kernel.org, vadim.fedorenko@linux.dev X-In-Reply-To: <20261130092003.1946901-2-mkl@pengutronix.de> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list