From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] USB: serial: usb_wwan: handle urb allocation failure
Date: Sat, 17 Oct 2026 14:35:15 +0200 [thread overview]
Message-ID: <20261017123515.1788872-1-johan@kernel.org> (raw)
Make sure to bail out from probe if URB allocation fails to avoid ever
dereferencing a NULL-pointer in usb_wwan_write() or on resume of an open
port.
Note that URB allocation is not expected to fail unless doing fault
injection.
The usb_wwan_write() issue was flagged by Sashiko.
Fixes: 58cfe9113e48 ("[PATCH] USB: add Option Card driver")
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/usb_wwan.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 6beb4062bda3..92362565796d 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -343,8 +343,7 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
/* Start reading from the IN endpoint */
for (i = 0; i < N_IN_URB; i++) {
urb = portdata->in_urbs[i];
- if (!urb)
- continue;
+
err = usb_submit_urb(urb, GFP_KERNEL);
if (err) {
dev_err(&port->dev,
@@ -465,6 +464,9 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
USB_DIR_IN, port,
buffer, IN_BUFLEN,
usb_wwan_indat_callback);
+ if (!urb)
+ goto bail_out_error;
+
portdata->in_urbs[i] = urb;
}
@@ -478,6 +480,9 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
USB_DIR_OUT, port,
buffer, OUT_BUFLEN,
usb_wwan_outdat_callback);
+ if (!urb)
+ goto bail_out_error2;
+
portdata->out_urbs[i] = urb;
}
--
2.55.0
next reply other threads:[~2026-10-17 12:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 12:35 Johan Hovold [this message]
2026-10-17 12:38 ` [PATCH] USB: serial: usb_wwan: handle urb allocation failure 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=20261017123515.1788872-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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