public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [usb?] memory leak in hub_event (4)
@ 2026-04-25  2:12 syzbot
  2026-04-27 11:40 ` Oliver Neukum
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: syzbot @ 2026-04-25  2:12 UTC (permalink / raw)
  To: gregkh, linux-kernel, linux-usb, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    dd6c438c3e64 Merge tag 'vfs-7.1-rc1.fixes' of git://git.ke..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15cf7702580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ac5083db84233db3
dashboard link: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=13cf7702580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17941c36580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/dea6ab846ab3/disk-dd6c438c.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/acebe380aa03/vmlinux-dd6c438c.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2cdbd012d0d3/bzImage-dd6c438c.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com

BUG: memory leak
unreferenced object 0xffff8881277dc000 (size 2048):
  comm "kworker/0:2", pid 1783, jiffies 4294946784
  hex dump (first 32 bytes):
    ff ff ff ff 31 00 00 00 00 00 00 00 00 00 00 00  ....1...........
    00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00  ................
  backtrace (crc 20105372):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4574 [inline]
    slab_alloc_node mm/slub.c:4898 [inline]
    __kmalloc_cache_noprof+0x371/0x480 mm/slub.c:5410
    kmalloc_noprof include/linux/slab.h:950 [inline]
    kzalloc_noprof include/linux/slab.h:1188 [inline]
    usb_alloc_dev+0x36/0x4e0 drivers/usb/core/usb.c:651
    hub_port_connect drivers/usb/core/hub.c:5470 [inline]
    hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
    port_event drivers/usb/core/hub.c:5871 [inline]
    hub_event+0x14d0/0x2180 drivers/usb/core/hub.c:5953
    process_one_work+0x277/0x5b0 kernel/workqueue.c:3302
    process_scheduled_works kernel/workqueue.c:3385 [inline]
    worker_thread+0x255/0x4a0 kernel/workqueue.c:3466
    kthread+0x14e/0x1a0 kernel/kthread.c:436
    ret_from_fork+0x219/0x490 arch/x86/kernel/process.c:158
    ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

BUG: memory leak
unreferenced object 0xffff888128b06c00 (size 1024):
  comm "kworker/0:2", pid 1783, jiffies 4294946815
  hex dump (first 32 bytes):
    09 02 49 00 02 01 00 10 40 00 00 00 00 00 00 00  ..I.....@.......
    00 00 00 00 00 00 00 00 89 b8 69 09 81 88 ff ff  ..........i.....
  backtrace (crc b43c3ef8):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4574 [inline]
    slab_alloc_node mm/slub.c:4898 [inline]
    __do_kmalloc_node mm/slub.c:5294 [inline]
    __kmalloc_noprof+0x3b7/0x550 mm/slub.c:5307
    kmalloc_noprof include/linux/slab.h:954 [inline]
    kzalloc_noprof include/linux/slab.h:1188 [inline]
    usb_get_configuration+0xeb/0x2110 drivers/usb/core/config.c:940
    usb_enumerate_device drivers/usb/core/hub.c:2527 [inline]
    usb_new_device+0x1b4/0x300 drivers/usb/core/hub.c:2665
    hub_port_connect drivers/usb/core/hub.c:5567 [inline]
    hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
    port_event drivers/usb/core/hub.c:5871 [inline]
    hub_event+0x1723/0x2180 drivers/usb/core/hub.c:5953
    process_one_work+0x277/0x5b0 kernel/workqueue.c:3302
    process_scheduled_works kernel/workqueue.c:3385 [inline]
    worker_thread+0x255/0x4a0 kernel/workqueue.c:3466
    kthread+0x14e/0x1a0 kernel/kthread.c:436
    ret_from_fork+0x219/0x490 arch/x86/kernel/process.c:158
    ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

BUG: memory leak
unreferenced object 0xffff88810c3d5a50 (size 8):
  comm "kworker/0:2", pid 1783, jiffies 4294946815
  hex dump (first 8 bytes):
    80 b8 69 09 81 88 ff ff                          ..i.....
  backtrace (crc 66af3167):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4574 [inline]
    slab_alloc_node mm/slub.c:4898 [inline]
    __do_kmalloc_node mm/slub.c:5294 [inline]
    __kmalloc_noprof+0x3b7/0x550 mm/slub.c:5307
    kmalloc_noprof include/linux/slab.h:954 [inline]
    kzalloc_noprof include/linux/slab.h:1188 [inline]
    usb_get_configuration+0x11d/0x2110 drivers/usb/core/config.c:945
    usb_enumerate_device drivers/usb/core/hub.c:2527 [inline]
    usb_new_device+0x1b4/0x300 drivers/usb/core/hub.c:2665
    hub_port_connect drivers/usb/core/hub.c:5567 [inline]
    hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
    port_event drivers/usb/core/hub.c:5871 [inline]
    hub_event+0x1723/0x2180 drivers/usb/core/hub.c:5953
    process_one_work+0x277/0x5b0 kernel/workqueue.c:3302
    process_scheduled_works kernel/workqueue.c:3385 [inline]
    worker_thread+0x255/0x4a0 kernel/workqueue.c:3466
    kthread+0x14e/0x1a0 kernel/kthread.c:436
    ret_from_fork+0x219/0x490 arch/x86/kernel/process.c:158
    ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

BUG: memory leak
unreferenced object 0xffff888113c25840 (size 64):
  comm "kworker/0:2", pid 1783, jiffies 4294946817
  hex dump (first 32 bytes):
    01 00 00 00 01 00 00 00 09 04 00 00 00 01 01 30  ...............0
    00 00 00 00 0a 00 00 00 9a b8 69 09 81 88 ff ff  ..........i.....
  backtrace (crc a90fa323):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4574 [inline]
    slab_alloc_node mm/slub.c:4898 [inline]
    __do_kmalloc_node mm/slub.c:5294 [inline]
    __kmalloc_noprof+0x3b7/0x550 mm/slub.c:5307
    kmalloc_noprof include/linux/slab.h:954 [inline]
    kzalloc_noprof include/linux/slab.h:1188 [inline]
    usb_parse_configuration drivers/usb/core/config.c:826 [inline]
    usb_get_configuration+0x88f/0x2110 drivers/usb/core/config.c:1002
    usb_enumerate_device drivers/usb/core/hub.c:2527 [inline]
    usb_new_device+0x1b4/0x300 drivers/usb/core/hub.c:2665
    hub_port_connect drivers/usb/core/hub.c:5567 [inline]
    hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
    port_event drivers/usb/core/hub.c:5871 [inline]
    hub_event+0x1723/0x2180 drivers/usb/core/hub.c:5953
    process_one_work+0x277/0x5b0 kernel/workqueue.c:3302
    process_scheduled_works kernel/workqueue.c:3385 [inline]
    worker_thread+0x255/0x4a0 kernel/workqueue.c:3466
    kthread+0x14e/0x1a0 kernel/kthread.c:436
    ret_from_fork+0x219/0x490 arch/x86/kernel/process.c:158
    ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

BUG: memory leak
unreferenced object 0xffff88811d54a500 (size 256):
  comm "kworker/0:2", pid 1783, jiffies 4294946821
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 08 a5 54 1d 81 88 ff ff  ..........T.....
    08 a5 54 1d 81 88 ff ff 20 e7 41 83 ff ff ff ff  ..T..... .A.....
  backtrace (crc 85d09f91):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4574 [inline]
    slab_alloc_node mm/slub.c:4898 [inline]
    __kmalloc_cache_noprof+0x371/0x480 mm/slub.c:5410
    kmalloc_noprof include/linux/slab.h:950 [inline]
    kzalloc_noprof include/linux/slab.h:1188 [inline]
    device_private_init drivers/base/core.c:3536 [inline]
    device_add+0x73c/0xc70 drivers/base/core.c:3587
    usb_new_device.cold+0x115/0x626 drivers/usb/core/hub.c:2695
    hub_port_connect drivers/usb/core/hub.c:5567 [inline]
    hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
    port_event drivers/usb/core/hub.c:5871 [inline]
    hub_event+0x1723/0x2180 drivers/usb/core/hub.c:5953
    process_one_work+0x277/0x5b0 kernel/workqueue.c:3302
    process_scheduled_works kernel/workqueue.c:3385 [inline]
    worker_thread+0x255/0x4a0 kernel/workqueue.c:3466
    kthread+0x14e/0x1a0 kernel/kthread.c:436
    ret_from_fork+0x219/0x490 arch/x86/kernel/process.c:158
    ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

connection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [syzbot] [usb?] memory leak in hub_event (4)
  2026-04-25  2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
@ 2026-04-27 11:40 ` Oliver Neukum
  2026-04-27 12:37   ` syzbot
  2026-04-27 14:19   ` Alan Stern
  2026-04-29 10:42 ` [PATCH] usb: core: hcd: fix possible deadlock in rh control transfers Oliver Neukum
  2026-04-29 10:45 ` [PATCH] sound: usb: caiaq: fix reference leak in probe error Oliver Neukum
  2 siblings, 2 replies; 10+ messages in thread
From: Oliver Neukum @ 2026-04-27 11:40 UTC (permalink / raw)
  To: syzbot, gregkh, linux-kernel, linux-usb, syzkaller-bugs

[-- Attachment #1: Type: text/plain, Size: 81 bytes --]

On 25.04.26 04:12, syzbot wrote:

#syz test: git://repo/address.git dd6c438c3e64

[-- Attachment #2: 0001-usb-core-fix-memory-of-error-case-in-usb_get_configu.patch --]
[-- Type: text/x-patch, Size: 1527 bytes --]

From 001175f4d2e1c2ceac98b4af2521fc4d0253d0c8 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Mon, 27 Apr 2026 13:35:38 +0200
Subject: [PATCH] usb: core: fix memory of error case in usb_get_configuration

Prior allocations need to be reversed if subsequent
allocations fail.

Fixes: dd2057e544dc9 ("USB: core: drop OOM message")
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
---
 drivers/usb/core/config.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 417140b012bb..67475ff81641 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -944,11 +944,11 @@ int usb_get_configuration(struct usb_device *dev)
 	length = ncfg * sizeof(char *);
 	dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
 	if (!dev->rawdescriptors)
-		return -ENOMEM;
+		goto bailout2;
 
 	desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
 	if (!desc)
-		return -ENOMEM;
+		goto bailout;
 
 	for (cfgno = 0; cfgno < ncfg; cfgno++) {
 		/* We grab just the first descriptor so we know how long
@@ -1012,6 +1012,15 @@ int usb_get_configuration(struct usb_device *dev)
 	dev->descriptor.bNumConfigurations = cfgno;
 
 	return result;
+
+bailout:
+	kfree(dev->rawdescriptors);
+	dev->rawdescriptors = NULL;
+bailout2:
+	kfree(dev->config);
+	dev->config = NULL;
+
+	return -ENOMEM;
 }
 
 void usb_release_bos_descriptor(struct usb_device *dev)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [syzbot] [usb?] memory leak in hub_event (4)
  2026-04-27 11:40 ` Oliver Neukum
@ 2026-04-27 12:37   ` syzbot
  2026-04-27 14:19   ` Alan Stern
  1 sibling, 0 replies; 10+ messages in thread
From: syzbot @ 2026-04-27 12:37 UTC (permalink / raw)
  To: gregkh, linux-kernel, linux-usb, oneukum, syzkaller-bugs

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo git://repo/address.git on commit dd6c438c3e64: failed to run ["git" "fetch" "--force" "--tags" "b7cf8f2fbfc36c709a08e0b9c77990e491473738"]: exit status 128


Tested on:

commit:         [unknown 
git tree:       git://repo/address.git dd6c438c3e64
kernel config:  https://syzkaller.appspot.com/x/.config?x=ac5083db84233db3
dashboard link: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
compiler:       
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1575b236580000


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [syzbot] [usb?] memory leak in hub_event (4)
  2026-04-27 11:40 ` Oliver Neukum
  2026-04-27 12:37   ` syzbot
@ 2026-04-27 14:19   ` Alan Stern
  2026-04-28 11:33     ` Oliver Neukum
  1 sibling, 1 reply; 10+ messages in thread
From: Alan Stern @ 2026-04-27 14:19 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: syzbot, gregkh, linux-kernel, linux-usb, syzkaller-bugs

On Mon, Apr 27, 2026 at 01:40:02PM +0200, Oliver Neukum wrote:
> On 25.04.26 04:12, syzbot wrote:
> 
> #syz test: git://repo/address.git dd6c438c3e64

> From 001175f4d2e1c2ceac98b4af2521fc4d0253d0c8 Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oneukum@suse.com>
> Date: Mon, 27 Apr 2026 13:35:38 +0200
> Subject: [PATCH] usb: core: fix memory of error case in usb_get_configuration
> 
> Prior allocations need to be reversed if subsequent
> allocations fail.
> 
> Fixes: dd2057e544dc9 ("USB: core: drop OOM message")
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
> ---
>  drivers/usb/core/config.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
> index 417140b012bb..67475ff81641 100644
> --- a/drivers/usb/core/config.c
> +++ b/drivers/usb/core/config.c
> @@ -944,11 +944,11 @@ int usb_get_configuration(struct usb_device *dev)
>  	length = ncfg * sizeof(char *);
>  	dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
>  	if (!dev->rawdescriptors)
> -		return -ENOMEM;
> +		goto bailout2;
>  
>  	desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
>  	if (!desc)
> -		return -ENOMEM;
> +		goto bailout;
>  
>  	for (cfgno = 0; cfgno < ncfg; cfgno++) {
>  		/* We grab just the first descriptor so we know how long
> @@ -1012,6 +1012,15 @@ int usb_get_configuration(struct usb_device *dev)
>  	dev->descriptor.bNumConfigurations = cfgno;
>  
>  	return result;
> +
> +bailout:
> +	kfree(dev->rawdescriptors);
> +	dev->rawdescriptors = NULL;
> +bailout2:
> +	kfree(dev->config);
> +	dev->config = NULL;
> +
> +	return -ENOMEM;
>  }

This is not needed.  dev->rawdescriptors and dev->config are deallocated 
in usb_destroy_configuration(), which gets called when the usb_device 
structure is released.

The memory leak must have a different cause.

Alan Stern

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [syzbot] [usb?] memory leak in hub_event (4)
  2026-04-27 14:19   ` Alan Stern
@ 2026-04-28 11:33     ` Oliver Neukum
  2026-04-28 15:12       ` Alan Stern
  0 siblings, 1 reply; 10+ messages in thread
From: Oliver Neukum @ 2026-04-28 11:33 UTC (permalink / raw)
  To: Alan Stern; +Cc: syzbot, gregkh, linux-kernel, linux-usb, syzkaller-bugs



On 27.04.26 16:19, Alan Stern wrote:
  
> This is not needed.  dev->rawdescriptors and dev->config are deallocated
> in usb_destroy_configuration(), which gets called when the usb_device
> structure is released.
> 
> The memory leak must have a different cause.

You are correct. Yet I can see no way for usb_destroy_configuration()
to not run. Hence we must be overlooking something.

	Regards
		Oliver


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [syzbot] [usb?] memory leak in hub_event (4)
  2026-04-28 11:33     ` Oliver Neukum
@ 2026-04-28 15:12       ` Alan Stern
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Stern @ 2026-04-28 15:12 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: syzbot, gregkh, linux-kernel, linux-usb, syzkaller-bugs

On Tue, Apr 28, 2026 at 01:33:20PM +0200, Oliver Neukum wrote:
> 
> 
> On 27.04.26 16:19, Alan Stern wrote:
> > This is not needed.  dev->rawdescriptors and dev->config are deallocated
> > in usb_destroy_configuration(), which gets called when the usb_device
> > structure is released.
> > 
> > The memory leak must have a different cause.
> 
> You are correct. Yet I can see no way for usb_destroy_configuration()
> to not run. Hence we must be overlooking something.

Maybe the usb_device structures are not being released at all.  For 
instance, the snd_usb_audio or snd_usb_caiaq driver may forget to drop a 
reference in an error pathway.

It seems odd that the bug report says there are 5 suspected memory leaks 
right after 5 devices have disconnected, yet the tracebacks are for 
different size allocations, implying that they all refer to the same 
device (i.e., not the same allocation for each of the 5 devices).  But 
it could just be a coincidence.

Alan Stern

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] usb: core: hcd: fix possible deadlock in rh control transfers
  2026-04-25  2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
  2026-04-27 11:40 ` Oliver Neukum
@ 2026-04-29 10:42 ` Oliver Neukum
  2026-04-29 10:45 ` [PATCH] sound: usb: caiaq: fix reference leak in probe error Oliver Neukum
  2 siblings, 0 replies; 10+ messages in thread
From: Oliver Neukum @ 2026-04-29 10:42 UTC (permalink / raw)
  To: syzbot+2afd7e71155c7e241560; +Cc: linux-usb, tiwai, Oliver Neukum

From within the SCSI error handler memory allocations must not
trigger IO. Handling errors in UAS and the storage driver may
involve resetting a device. The thread doing the reset itself
relies on VM magic. However, that is insufficient, as resetting
a device involves resuming it. Resumption as well as resetting
involves conrol transfers to the parent of the device to be reset.
That may be a root hub. Hence usbcore must heed the flags passed
to usb_submit_urb() processing control transfers to root hubs.

The problem exist since the storage driver has been merged.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/core/hcd.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 89221f1ce769..29c74ed40526 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -448,7 +448,8 @@ rh_string(int id, struct usb_hcd const *hcd, u8 *data, unsigned len)
 
 
 /* Root hub control transfers execute synchronously */
-static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
+static int rh_call_control(struct usb_hcd *hcd,
+		struct urb *urb, gfp_t mem_flags)
 {
 	struct usb_ctrlrequest *cmd;
 	u16		typeReq, wValue, wIndex, wLength;
@@ -483,8 +484,8 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
 	 * tbuf should be at least as big as the
 	 * USB hub descriptor.
 	 */
-	tbuf_size =  max_t(u16, sizeof(struct usb_hub_descriptor), wLength);
-	tbuf = kzalloc(tbuf_size, GFP_KERNEL);
+	tbuf_size = max_t(u16, sizeof(struct usb_hub_descriptor), wLength);
+	tbuf = kzalloc(tbuf_size, mem_flags);
 	if (!tbuf) {
 		status = -ENOMEM;
 		goto err_alloc;
@@ -809,12 +810,13 @@ static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb)
 	return retval;
 }
 
-static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb)
+static int rh_urb_enqueue(struct usb_hcd *hcd,
+		struct urb *urb, gfp_t mem_flags)
 {
 	if (usb_endpoint_xfer_int(&urb->ep->desc))
 		return rh_queue_status (hcd, urb);
 	if (usb_endpoint_xfer_control(&urb->ep->desc))
-		return rh_call_control (hcd, urb);
+		return rh_call_control(hcd, urb, mem_flags);
 	return -EINVAL;
 }
 
@@ -1535,7 +1537,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
 	 */
 
 	if (is_root_hub(urb->dev)) {
-		status = rh_urb_enqueue(hcd, urb);
+		status = rh_urb_enqueue(hcd, urb, mem_flags);
 	} else {
 		status = map_urb_for_dma(hcd, urb, mem_flags);
 		if (likely(status == 0)) {
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] sound: usb: caiaq: fix reference leak in probe error
  2026-04-25  2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
  2026-04-27 11:40 ` Oliver Neukum
  2026-04-29 10:42 ` [PATCH] usb: core: hcd: fix possible deadlock in rh control transfers Oliver Neukum
@ 2026-04-29 10:45 ` Oliver Neukum
  2026-04-29 10:53   ` Takashi Iwai
  2 siblings, 1 reply; 10+ messages in thread
From: Oliver Neukum @ 2026-04-29 10:45 UTC (permalink / raw)
  To: syzbot+2afd7e71155c7e241560; +Cc: linux-usb, tiwai, Oliver Neukum

If probing a device fails early a reference to a device
is leaked.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 sound/usb/caiaq/device.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 8af0c04041ee..1a9ddbdc2cd1 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -442,7 +442,8 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
 
 	if (usb_set_interface(usb_dev, 0, 1) != 0) {
 		dev_err(dev, "can't set alt interface.\n");
-		return -EIO;
+		err = -EIO;
+		goto dev_err_put;
 	}
 
 	usb_init_urb(&cdev->ep1_in_urb);
@@ -462,14 +463,18 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
 	if (usb_urb_ep_type_check(&cdev->ep1_in_urb) ||
 	    usb_urb_ep_type_check(&cdev->midi_out_urb)) {
 		dev_err(dev, "invalid EPs\n");
-		return -EINVAL;
+		err = -EINVAL;
+		goto dev_err_put;
 	}
 
 	init_waitqueue_head(&cdev->ep1_wait_queue);
 	init_waitqueue_head(&cdev->prepare_wait_queue);
 
-	if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0)
-		return -EIO;
+	if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0) {
+		err = -EIO;
+		goto dev_err_put;
+	}
+
 
 	err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
 	if (err)
@@ -520,6 +525,14 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
 
  err_kill_urb:
 	usb_kill_urb(&cdev->ep1_in_urb);
+
+	/*
+ 	 * private_free has not been set.
+	 * Undoing the usb_get_dev() from
+	 * create_card()
+	 */
+ err_dev_put:
+	usb_put_dev(usb_dev);
 	return err;
 }
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] sound: usb: caiaq: fix reference leak in probe error
  2026-04-29 10:45 ` [PATCH] sound: usb: caiaq: fix reference leak in probe error Oliver Neukum
@ 2026-04-29 10:53   ` Takashi Iwai
  2026-04-29 11:05     ` Oliver Neukum
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2026-04-29 10:53 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: syzbot+2afd7e71155c7e241560, linux-usb, tiwai

On Wed, 29 Apr 2026 12:45:24 +0200,
Oliver Neukum wrote:
> 
> If probing a device fails early a reference to a device
> is leaked.
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.com>

Thanks, but I believe it's been already fixed in my tree for 7.1-rc2:
7a5f1cd22d47f8ca4b760b6334378ae42c1bd24b
    ALSA: caiaq: fix usb_dev refcount leak on probe failure

Also, there are a couple of fixes for caiaq queued for 7.1-rc2, too.


Takashi

> ---
>  sound/usb/caiaq/device.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
> index 8af0c04041ee..1a9ddbdc2cd1 100644
> --- a/sound/usb/caiaq/device.c
> +++ b/sound/usb/caiaq/device.c
> @@ -442,7 +442,8 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
>  
>  	if (usb_set_interface(usb_dev, 0, 1) != 0) {
>  		dev_err(dev, "can't set alt interface.\n");
> -		return -EIO;
> +		err = -EIO;
> +		goto dev_err_put;
>  	}
>  
>  	usb_init_urb(&cdev->ep1_in_urb);
> @@ -462,14 +463,18 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
>  	if (usb_urb_ep_type_check(&cdev->ep1_in_urb) ||
>  	    usb_urb_ep_type_check(&cdev->midi_out_urb)) {
>  		dev_err(dev, "invalid EPs\n");
> -		return -EINVAL;
> +		err = -EINVAL;
> +		goto dev_err_put;
>  	}
>  
>  	init_waitqueue_head(&cdev->ep1_wait_queue);
>  	init_waitqueue_head(&cdev->prepare_wait_queue);
>  
> -	if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0)
> -		return -EIO;
> +	if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0) {
> +		err = -EIO;
> +		goto dev_err_put;
> +	}
> +
>  
>  	err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
>  	if (err)
> @@ -520,6 +525,14 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
>  
>   err_kill_urb:
>  	usb_kill_urb(&cdev->ep1_in_urb);
> +
> +	/*
> + 	 * private_free has not been set.
> +	 * Undoing the usb_get_dev() from
> +	 * create_card()
> +	 */
> + err_dev_put:
> +	usb_put_dev(usb_dev);
>  	return err;
>  }
>  
> -- 
> 2.54.0
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sound: usb: caiaq: fix reference leak in probe error
  2026-04-29 10:53   ` Takashi Iwai
@ 2026-04-29 11:05     ` Oliver Neukum
  0 siblings, 0 replies; 10+ messages in thread
From: Oliver Neukum @ 2026-04-29 11:05 UTC (permalink / raw)
  To: Takashi Iwai, Oliver Neukum; +Cc: syzbot+2afd7e71155c7e241560, linux-usb, tiwai



On 29.04.26 12:53, Takashi Iwai wrote:
> On Wed, 29 Apr 2026 12:45:24 +0200,
> Oliver Neukum wrote:
>>
>> If probing a device fails early a reference to a device
>> is leaked.
>>
>> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> 
> Thanks, but I believe it's been already fixed in my tree for 7.1-rc2:
> 7a5f1cd22d47f8ca4b760b6334378ae42c1bd24b
>      ALSA: caiaq: fix usb_dev refcount leak on probe failure
> 
> Also, there are a couple of fixes for caiaq queued for 7.1-rc2, too.

Very good. Such things happen.

	Regards
		Oliver


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-04-29 11:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-25  2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
2026-04-27 11:40 ` Oliver Neukum
2026-04-27 12:37   ` syzbot
2026-04-27 14:19   ` Alan Stern
2026-04-28 11:33     ` Oliver Neukum
2026-04-28 15:12       ` Alan Stern
2026-04-29 10:42 ` [PATCH] usb: core: hcd: fix possible deadlock in rh control transfers Oliver Neukum
2026-04-29 10:45 ` [PATCH] sound: usb: caiaq: fix reference leak in probe error Oliver Neukum
2026-04-29 10:53   ` Takashi Iwai
2026-04-29 11:05     ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox