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=1796339540; b=jJMEnZWEfqNHfSm04+ur1v8c9DW3ai6vVYLMbu20kho7LhweCoir8WnDaB24AG4kwmjb zvyRkKN+nEyfbA+zbVp57jkZWJgJXfwpC2Mpp8hKjsqT5Oo5gEB2vBPEvXKyPkz/V5HKr dIi5fnLvP9jugtFqBI0rKbUBWYP5ah2tRSB9Ihf5PU2KjkwYYiYac6+gchXu9TwFPHwjv ITipMogyZy5WixTGRAu0Peqvv1BVpmwcq1ilvEc/TBI2SQZ7hFMuv6ulhW0aOg2tQqT1E kSeTtWUGt6FH0GAdUQN2HAcOyG9B+zUnOgEq2KT9jpSR43LmawT1KEi+bqyD8+dqbfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796339540; 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=vuWaLKckY6JYPiA28Qg2WzEMDkuIxjHv3cg9QZGWYQI=; b=B5S3s5AqPfStzLMIahoFXZ3cLdK04r3hJY6At57uRfz0A3eXjCnhvtz6b4DLMdr/d8iS wTup6FDixGNsy84hFN8P1ePKy6UOa4AWa205qlfnBam9JbkT9cAYREvM1gPvwPOHV1Cop I9XnIn2MbKtULyqH+7ZAv6CuRy05LcRQYttMd8HhpiQmzvzrA/e3f8U3h3DLWxd/tBP5Y 8fWks00knSS4uF77Ptr6nkUVB7g6122GI8mG/qcnUUjZtRxtfcVn1zKno8ePBOcDF8OH0 kpBWt+aT+5tzgTGQgz4WIyl+rOsf/z+1foXfoWiZajcU4h1SXFirGsIIchKqGGytBBw== 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=IR6yUm3s; 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 14FA9606A330; Thu, 3 Dec 2026 23:12:19 +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=IR6yUm3s Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EC271F000C2; Thu, 3 Dec 2026 23:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796339539; bh=vuWaLKckY6JYPiA28Qg2WzEMDkuIxjHv3cg9QZGWYQI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IR6yUm3sozUcr6a8CwxCZA96SmNtuOrKA808rlvl2Pr1zRmnmN/b4N9UF7YyEMuww ch6m3cFcxc9gDsWBSE2iBpvA2F33zH8Ul7y+FVGJNOWJeext69RYKOUokmJ5ivZOI6 ea3eN2AcLBUeoXKhUzvlVvRkKrqDwxTenSj8VrhPK7ALk07XjqujqSgoJqLfSrgCRH mO/rLvLz0ZcGTkZrthNi0iD7//eQySAotUPIl5N7PolmylS5wlB/O0Xd58L/z+gaqw fjm4b4A4naLazK/wIPpAXodVK2iZOaWGoJ0gx4Sg2bZPsRgjodNNDbK5sPyqzUwB1W Tzm2u9CZoxNwA== Subject: Re: [PATCH net-next 16/23] can: peak_usb: register the netdevs only once all channels are set up 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, s.grosjean@peak-system.fr, stable@vger.kernel.org Date: Thu, 03 Dec 2026 23:12:18 +0000 Message-ID: <179633953890.3146.16528120683494522758@kernel.org> In-Reply-To: <20261202230853.2665144-17-mkl@pengutronix.de> References: <20261202230853.2665144-17-mkl@pengutronix.de> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: stable@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 more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] After this patch, pcan_usb_get_can_channel_id() carries a comment saying it uses dev_xxx() instead of netdev_xxx() because it is now… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but it is a use- after-free in the same probe/disconnect lifecycle the patch reworks. -- can: peak_usb: register the netdevs only once all channels are set up This commit moves register_candev() out of peak_usb_create_dev() and into peak_usb_probe(). The netdevs are now registered only after dev_init(), dev_set_bus() and dev_get_can_channel_id() have run for every channel of the interface, and peak_usb_disconnect() unregisters only the netdevs flagged with PCAN_USB_STATE_REGISTERED. Link: https://patch.msgid.link/20261126-canfd_check_channel_idx-v9-7-abe0099b4585@peak-system.fr > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c > index 90f69afcba974..451d084215049 100644 > --- a/drivers/net/can/usb/peak_usb/pcan_usb.c > +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c > @@ -390,9 +390,12 @@ static int pcan_usb_get_can_channel_id(struct peak_usb_device *dev, u32 *can_ch_ > int err; > > err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_DEVID, PCAN_USB_GET, args); > + /* explicit use of dev_xxx() instead of netdev_xxx() here: this is > + * also called during probe, before the netdev is registered. > + */ > if (err) > - netdev_err(dev->netdev, "getting can channel id failure: %d\n", err); > - > + dev_err(dev->netdev->dev.parent, > + "getting can channel id failure: %d\n", err); > else > *can_ch_id = args[0]; [Severity: Low] The new comment says dev_xxx() is used here because this runs during probe, before the netdev is registered. Shouldn't the same apply to the helpers on this path? pcan_usb_wait_rsp(), which is called just above, and pcan_usb_send_cmd() still log through netdev_err(dev->netdev, ...): pcan_usb_wait_rsp() { ... if (err) netdev_err(dev->netdev, "waiting rsp f=0x%x n=0x%x failure: %d\n", f, n, err); ... } The same applies to pcan_usb_pro_send_req() (netdev_info), pcan_usb_pro_send_cmd() and pcan_usb_pro_wait_rsp() (netdev_err) in pcan_usb_pro.c, and to pcan_usb_fd_send_cmd() (netdev_err) in pcan_usb_fd.c. With this patch, all of the following run in peak_usb_create_dev() before peak_usb_probe() calls register_candev(): dev_init(): pcan_usb_init()->pcan_usb_get_serial()->pcan_usb_wait_rsp() pcan_usb_pro_init() pcan_usb_fd_init() dev_set_bus(dev, 0) dev_get_can_channel_id() If a USB command fails during probe, __netdev_printk() prints the message with the "can%d" template name and tags it "(unnamed net_device) (uninitialized)". Could these helpers be converted too, so the code matches the new comment? They are still unconverted at the end of the series. > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c > index f5c39b43b0fa1..e5198ec5c760d 100644 > --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c > +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c [ ... ] > @@ -1078,11 +1059,15 @@ static void peak_usb_disconnect(struct usb_interface *intf) > for (dev = usb_get_intfdata(intf); dev; dev = dev_prev_siblings) { > struct net_device *netdev = dev->netdev; > char name[IFNAMSIZ]; > + bool registered; > > dev_prev_siblings = dev->prev_siblings; > strscpy(name, netdev->name, IFNAMSIZ); > > - unregister_candev(netdev); > + /* on probe error, some netdevs may not be registered yet */ > + registered = test_bit(PCAN_USB_STATE_REGISTERED, &dev->state); > + if (registered) > + unregister_candev(netdev); > > kfree(dev->cmd_buf); > dev->next_siblings = NULL; > @@ -1090,7 +1075,8 @@ static void peak_usb_disconnect(struct usb_interface *intf) > dev->adapter->dev_free(dev); > > free_candev(netdev); [Severity: High] This is a pre-existing issue, not one introduced by this patch, but it is in the probe/disconnect code this patch reworks. Can the PCAN-USB restart_timer still fire after free_candev() has freed it? pcan_usb_init() calls timer_setup(&pdev->restart_timer, pcan_usb_restart, 0). The timer lives in struct pcan_usb, which is the netdev private area. A CAN restart can come from bus-off with restart-ms set, or from "ip link set canX type can restart". In that case peak_usb_set_mode()->peak_usb_restart()->pcan_usb_restart_async() submits a URB that is not anchored. Its completion arms the timer unconditionally, even on -ESHUTDOWN or -ENOENT: pcan_usb_restart_pending() { ... mod_timer(&pdev->restart_timer, jiffies + msecs_to_jiffies(PCAN_USB_STARTUP_TIMEOUT)); ... } Nothing under drivers/net/can/usb/peak_usb/ cancels this timer. The pcan_usb adapter has no dev_free, dev_stop or dev_exit callback, and peak_usb_ndo_stop() doesn't touch the timer. Suppose the device is unplugged or unbound (sysfs unbind, rmmod) while the restart URB is in flight or within the 10 ms timer window. Then either pcan_usb_restart_pending() calls mod_timer() on freed memory, or pcan_usb_restart() runs from the timer softirq on freed memory: pcan_usb_restart() peak_usb_restart_complete(dev) writes dev->can.state netif_wake_queue() on the freed netdev Should the timer be shut down, and the restart URB killed, before free_candev() runs here? This is still present at the end of the series. > - dev_info(&intf->dev, "%s removed\n", name); > + if (registered) > + dev_info(&intf->dev, "%s removed\n", name); > } [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202230853.2665144-2-mkl%40pengutronix.de