* [PATCH] usb: gadget: f_midi: initialize work in f_midi_alloc()
@ 2026-08-15 5:40 Jeffin Philip
2026-08-16 10:43 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Jeffin Philip @ 2026-08-15 5:40 UTC (permalink / raw)
To: gregkh
Cc: jeffinphilip14, victor.krawiec, fanwu01, christophe.jaillet, kees,
balbi, tiwai, dave, linux-usb, linux-kernel, stable,
syzbot+d5fa3d224505c8610702
f_midi_alloc initializes free_ref to 1 and it can only be incremented
when a sound card is registered via f_midi_register_card().
f_midi_register_card() is only called in f_midi_bind() which actually
performs INIT_WORK. If f_midi_bind() is never run, work is not
initialized and the if condition in f_midi_free becomes true,
this results in a warning later in __flush_work as work->func = 0.
Fix this by moving INIT_WORK from f_midi_bind() to f_midi_alloc().
Reported-by: syzbot+d5fa3d224505c8610702@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d5fa3d224505c8610702
Fixes: 8653d71ce376 ("usb/gadget: f_midi: Replace tasklet with work")
Cc: stable@vger.kernel.org
Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
---
drivers/usb/gadget/function/f_midi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index fba8cf787d6c..63fb6ee70a3d 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -879,7 +879,6 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f)
int status, n, jack = 1, i = 0, endpoint_descriptor_index = 0;
midi->gadget = cdev->gadget;
- INIT_WORK(&midi->work, f_midi_in_work);
status = f_midi_register_card(midi);
if (status < 0)
goto fail_register;
@@ -1377,6 +1376,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
status = -ENOMEM;
goto midi_free;
}
+ INIT_WORK(&midi->work, f_midi_in_work);
midi->out_ports = opts->out_ports;
midi->index = opts->index;
midi->buflen = opts->buflen;
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] usb: gadget: f_midi: initialize work in f_midi_alloc()
2026-08-15 5:40 [PATCH] usb: gadget: f_midi: initialize work in f_midi_alloc() Jeffin Philip
@ 2026-08-16 10:43 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-08-16 10:43 UTC (permalink / raw)
To: Jeffin Philip
Cc: gregkh, victor.krawiec, fanwu01, christophe.jaillet, kees, balbi,
tiwai, dave, linux-usb, linux-kernel, stable,
syzbot+d5fa3d224505c8610702
On Sat, 15 Aug 2026 07:40:06 +0200,
Jeffin Philip wrote:
>
> f_midi_alloc initializes free_ref to 1 and it can only be incremented
> when a sound card is registered via f_midi_register_card().
> f_midi_register_card() is only called in f_midi_bind() which actually
> performs INIT_WORK. If f_midi_bind() is never run, work is not
> initialized and the if condition in f_midi_free becomes true,
> this results in a warning later in __flush_work as work->func = 0.
> Fix this by moving INIT_WORK from f_midi_bind() to f_midi_alloc().
>
> Reported-by: syzbot+d5fa3d224505c8610702@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d5fa3d224505c8610702
> Fixes: 8653d71ce376 ("usb/gadget: f_midi: Replace tasklet with work")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-16 10:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15 5:40 [PATCH] usb: gadget: f_midi: initialize work in f_midi_alloc() Jeffin Philip
2026-08-16 10:43 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox