From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 829231F000C1; Tue, 1 Dec 2026 09:41:29 +0000 (UTC) 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== Subject: Re: [PATCH net-next 1/9] can: gs_usb: gs_usb_probe(): init netdev completely before register_candev() From: netdev-bot+sashiko@kernel.org To: mkl@pengutronix.de 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 Date: Tue, 01 Dec 2026 09:41:29 +0000 Message-ID: <179611808903.3146.10926780520247936704@kernel.org> In-Reply-To: <20261130092003.1946901-2-mkl@pengutronix.de> References: <20261130092003.1946901-2-mkl@pengutronix.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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