From: syzbot <syzbot+bbb6dad313f4aaa8da6b@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Forwarded: [PATCH] usb: gadget: f_midi2: Fix null dereference
Date: Tue, 28 Jul 2026 10:25:21 -0700 [thread overview]
Message-ID: <6a68e601.e3659fcc.2a40b8.0018.GAE@google.com> (raw)
In-Reply-To: <6a68b182.4c659fcc.19cd90.0020.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH] usb: gadget: f_midi2: Fix null dereference
Author: michail.tatas@gmail.com
#syz test
f_midi2_bind only binds if
if (... != SNDRV_UMP_DIR_OUTPUT)
...
if (... != SNDRV_UMP_DIR_INPUT)
...
When f_midi2_set_alt gets called, it uncoditionally calls
f_midi2_stop_eps which triggers a null dereference in
f_midi2_free_ep_reqs
Add guard to catch dereference in f_midi2_free_ep_reqs like
f_midi2_drop_reqs already has
Signed-off-by: Michail Tatas <michail.tatas@gmail.com>
---
drivers/usb/gadget/function/f_midi2.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/function/f_midi2.c b/drivers/usb/gadget/function/f_midi2.c
index 19fdac024343..b9bb09c4b51a 100644
--- a/drivers/usb/gadget/function/f_midi2.c
+++ b/drivers/usb/gadget/function/f_midi2.c
@@ -1163,6 +1163,9 @@ static void f_midi2_free_ep_reqs(struct f_midi2_usb_ep *usb_ep)
struct f_midi2 *midi2 = usb_ep->card;
int i;
+ if (!usb_ep->usb_ep || !usb_ep->num_reqs)
+ return;
+
for (i = 0; i < midi2->info.num_reqs; i++) {
if (!usb_ep->reqs[i].req)
continue;
@@ -1203,6 +1206,9 @@ static int f_midi2_init_ep(struct f_midi2 *midi2, struct f_midi2_ep *ep,
/* Free EP */
static void f_midi2_free_ep(struct f_midi2_usb_ep *usb_ep)
{
+ if(!usb_ep->usb_ep)
+ return;
+
f_midi2_drop_reqs(usb_ep);
f_midi2_free_ep_reqs(usb_ep);
--
2.43.0
prev parent reply other threads:[~2026-07-28 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 13:41 [syzbot] [usb?] general protection fault in f_midi2_stop_eps syzbot
2026-07-28 15:59 ` Forwarded: [PATCH] usb: gadget: f_midi2: Fix null dereference syzbot
2026-07-28 17:25 ` syzbot
2026-07-28 17:25 ` syzbot [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=6a68e601.e3659fcc.2a40b8.0018.GAE@google.com \
--to=syzbot+bbb6dad313f4aaa8da6b@syzkaller.appspotmail.com \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.