Linux USB
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] USB: serial: garmin_gps: explicitly stop read urb on unbind
Date: Sat, 17 Oct 2026 14:10:19 +0200	[thread overview]
Message-ID: <20261017121019.1777984-1-johan@kernel.org> (raw)

The garmin_gps read URB may be submitted from the interrupt URB
completion handler and should therefore be stopped after stopping the
interrupt URB and before freeing the port data during port unbind.

When a USB serial device is disconnected (or unbound through sysfs),
USB serial core stops and poisons the port URBs before unbinding the
port however so there is no risk for a use-after-free in the read URB
completion handler even if the driver does not stop it in its remove()
callback.

Stop the read URB explicitly for consistency, to avoid relying on core
and to prevent false positive reports from LLMs.

Note that this was erroneously flagged as a use-after-free by Sashiko.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/garmin_gps.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 8020149f5658..1853dc8a747d 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1402,6 +1402,7 @@ static void garmin_port_remove(struct usb_serial_port *port)
 
 	usb_kill_anchored_urbs(&garmin_data_p->write_urbs);
 	usb_kill_urb(port->interrupt_in_urb);
+	usb_kill_urb(port->read_urb);
 	timer_shutdown_sync(&garmin_data_p->timer);
 	kfree(garmin_data_p);
 }
-- 
2.55.0


             reply	other threads:[~2026-10-17 12:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 12:10 Johan Hovold [this message]
2026-10-17 12:15 ` [PATCH] USB: serial: garmin_gps: explicitly stop read urb on unbind sashiko-bot

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=20261017121019.1777984-1-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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