From: Prashanth K <prashanth.k@oss.qualcomm.com>
To: brianellis@gotenna.com, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kuen-Han Tsai <khtsai@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: u_serial: fix NULL deref in gs_close() after failed open
Date: Wed, 16 Sep 2026 14:31:01 +0530 [thread overview]
Message-ID: <75a26e11-8780-41de-aa69-d5cd34d68bb3@oss.qualcomm.com> (raw)
In-Reply-To: <20260910-u_serial-gs-close-null-v1-1-9a5e848b1dfb@gotenna.com>
On 9/11/2026 1:23 AM, Brian Ellis via B4 Relay wrote:
> From: Brian Ellis <brianellis@gotenna.com>
>
> gs_close() dereferences tty->driver_data without checking it:
>
> struct gs_port *port = tty->driver_data;
> struct gserial *gser;
>
> spin_lock_irq(&port->port_lock);
>
[...]
> diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> index cdd1dfc66..5bbb4d04b 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -695,6 +695,13 @@ static void gs_close(struct tty_struct *tty, struct file *file)
> struct gs_port *port = tty->driver_data;
> struct gserial *gser;
>
> + /*
> + * tty_open() calls tty_release(), and hence this, when ->open()
> + * failed before gs_open() had set tty->driver_data.
> + */
The patch looks good.
Minor nitpick, can you rephrase this comment?
> + if (!port)
> + return;
> +
> spin_lock_irq(&port->port_lock);
>
> if (port->port.count != 1) {
>
> ---
> base-commit: be4219dd98608736e13e0b790ef742b76a13254d
> change-id: 20260910-u_serial-gs-close-null-a80a436666e8
>
> Best regards,
Regards,
Prashanth K
prev parent reply other threads:[~2026-09-16 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 19:53 Brian Ellis via B4 Relay
2026-09-16 9:01 ` Prashanth K [this message]
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=75a26e11-8780-41de-aa69-d5cd34d68bb3@oss.qualcomm.com \
--to=prashanth.k@oss.qualcomm.com \
--cc=brianellis@gotenna.com \
--cc=gregkh@linuxfoundation.org \
--cc=khtsai@google.com \
--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
all inboxes | Powered by JetHome®