From: Tristan Madani <tristmd@gmail.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>
Cc: "Stéphane Grosjean" <s.grosjean@peak-system.fr>,
"Wolfgang Grandegger" <wg@grandegger.com>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
"Tristan Madani" <tristan@talencesecurity.com>
Subject: [PATCH net] can: peak_usb: add missing dev_free callback to cancel restart_timer
Date: Fri, 23 Oct 2026 19:54:00 +0000 [thread overview]
Message-ID: <20261023195400.3531721-1-tristmd@gmail.com> (raw)
From: Tristan Madani <tristan@talencesecurity.com>
The PCAN-USB adapter uses a restart_timer for bus error recovery
but does not define a dev_free callback. When the device is
unplugged, peak_usb_disconnect() calls free_candev() without
cancelling the timer. If a bus error armed the timer via
mod_timer() and USB disconnect races with it, the timer fires on
freed memory.
Add a pcan_usb_free() callback that cancels the restart_timer,
and register it as the adapter dev_free handler.
Fixes: 46be265d3388 ("can: usb: PEAK-System Technik PCAN-USB specific part")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/can/usb/peak_usb/pcan_usb.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 8fd058c328564..b0b3c76b2ccb8 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -882,6 +882,14 @@ static int pcan_usb_start(struct peak_usb_device *dev)
return pcan_usb_set_ext_vcc(dev, 0);
}
+static void pcan_usb_free(struct peak_usb_device *dev)
+{
+ struct pcan_usb *pdev =
+ container_of(dev, struct pcan_usb, dev);
+
+ timer_shutdown_sync(&pdev->restart_timer);
+}
+
static int pcan_usb_init(struct peak_usb_device *dev)
{
struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev);
@@ -1051,6 +1059,7 @@ const struct peak_usb_adapter pcan_usb = {
.dev_decode_buf = pcan_usb_decode_buf,
.dev_encode_msg = pcan_usb_encode_msg,
.dev_start = pcan_usb_start,
+ .dev_free = pcan_usb_free,
.dev_restart_async = pcan_usb_restart_async,
.do_get_berr_counter = pcan_usb_get_berr_counter,
};
--
2.47.3
next reply other threads:[~2026-10-23 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 19:54 Tristan Madani [this message]
2026-10-25 9:02 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023195400.3531721-1-tristmd@gmail.com \
--to=tristmd@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=s.grosjean@peak-system.fr \
--cc=stable@vger.kernel.org \
--cc=tristan@talencesecurity.com \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®