From: "Michał Nazarewicz" <mina86@mina86.com>
To: zjamg <ndaugoing@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Robert Baldyga <r.baldyga@samsung.com>,
Felipe Balbi <balbi@ti.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuchao Zhang <ndaugoing@gmail.com>,
stable@vger.kernel.org
Subject: Re: [RESEND PATCH 1/1] usb: gadget: f_fs: Fix NULL pointer dereference in FUNCTIONFS_ENDPOINT_DESC
Date: Fri, 18 Sep 2026 12:03:37 +0200 [thread overview]
Message-ID: <ag6hspo092vj0q0uehcbkf4f@mina86.com> (raw)
In-Reply-To: <20260918005438.81263-2-ndaugoing@gmail.com>
On Fri, Sep 18 2026, zjamg wrote:
> From: Yuchao Zhang <ndaugoing@gmail.com>
>
> Fixes: c559a3534109 ("usb: gadget: f_fs: add ioctl returning ep descriptor")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuchao Zhang <ndaugoing@gmail.com>
Acked-by: Michał Nazarewicz <mina86@mina86.com>
> ---
> drivers/usb/gadget/function/f_fs.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 43962e05eacf..c64a268e98a4 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -1877,8 +1877,9 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
> break;
> case FUNCTIONFS_ENDPOINT_DESC:
> {
> + const struct usb_endpoint_descriptor *desc;
> + struct usb_endpoint_descriptor desc1;
> int desc_idx;
> - struct usb_endpoint_descriptor desc1, *desc;
>
> switch (epfile->ffs->gadget->speed) {
> case USB_SPEED_SUPER:
> @@ -1892,7 +1893,17 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
> desc_idx = 0;
> }
>
> - desc = epfile->ep->descs[desc_idx];
> + do {
> + desc = epfile->ep->descs[desc_idx];
> + } while (!desc && --desc_idx >= 0);
> +
> + if (!desc)
> + desc = epfile->ep->ep->desc;
IIUC, this will never be non-NULL if all the descriptors are NULL. Then
again, it probably won’t hurt, so dosen’t matter one way or another.
> + if (!desc) {
> + ret = -EINVAL;
> + break;
> + }
> +
> memcpy(&desc1, desc, desc->bLength);
>
> spin_unlock_irq(&epfile->ffs->eps_lock);
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴィツ
«If at first you don’t succeed, give up skydiving»
prev parent reply other threads:[~2026-09-18 10:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 0:54 [RESEND PATCH 0/1] usb: gadget: f_fs: fix " zjamg
2026-09-18 0:54 ` [RESEND PATCH 1/1] usb: gadget: f_fs: Fix " zjamg
2026-09-18 10:03 ` Michał Nazarewicz [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=ag6hspo092vj0q0uehcbkf4f@mina86.com \
--to=mina86@mina86.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ndaugoing@gmail.com \
--cc=r.baldyga@samsung.com \
--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®