* Forwarded: [PATCH] usb: core: fix memory leak in usb_new_device() error path
2026-04-25 2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
@ 2026-04-25 6:36 ` syzbot
2026-04-25 7:52 ` Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure syzbot
` (5 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2026-04-25 6:36 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] usb: core: fix memory leak in usb_new_device() error path
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
When usb_new_device() fails, it jumps to the 'fail' label which calls
pm_runtime_disable() but never balances the earlier
pm_runtime_get_noresume() call made at the top of the function.
This leaves the PM runtime usage count elevated, preventing
usb_put_dev() in hub_port_connect() from dropping the refcount to zero.
As a result, usb_release_dev() never fires and usb_destroy_configuration()
is never called, leaking all memory allocated during enumeration:
- struct usb_device (2048 bytes) via usb_alloc_dev()
- raw config descriptor (1024 bytes) via usb_get_configuration()
- config metadata ( 8 bytes) via usb_get_configuration()
- interface descriptor ( 64 bytes) via usb_parse_configuration()
- struct device_private ( 256 bytes) via device_private_init()
Fix this by adding pm_runtime_put_noidle() on the fail path to balance
the pm_runtime_get_noresume() at the top of the function.
pm_runtime_put_noidle() is correct here rather than pm_runtime_put()
because we are in a teardown path and must not trigger autosuspend
scheduling.
Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
Signed-off-by: Deepanshu kartikey <kartikey406@gmail.com>
---
drivers/usb/core/hub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24960ba9caa9..148fadfbc30b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2733,6 +2733,7 @@ int usb_new_device(struct usb_device *udev)
usb_set_device_state(udev, USB_STATE_NOTATTACHED);
pm_runtime_disable(&udev->dev);
pm_runtime_set_suspended(&udev->dev);
+ pm_runtime_put_noidle(&udev->dev);
return err;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
2026-04-25 2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
2026-04-25 6:36 ` Forwarded: [PATCH] usb: core: fix memory leak in usb_new_device() error path syzbot
@ 2026-04-25 7:52 ` syzbot
2026-04-25 8:58 ` Forwarded: [PATCH] usb: core: hub: fix memory leak in hub_port_connect syzbot
` (4 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2026-04-25 7:52 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
create_card() takes a reference on the USB device with usb_get_dev()
and stores the matching usb_put_dev() in card_free(), which is
installed as the snd_card's ->private_free destructor.
However, ->private_free is only assigned near the end of init_card(),
after several failure points (usb_set_interface(), EP type checks,
usb_submit_urb(), the EP1_CMD_GET_DEVICE_INFO exchange, and its
timeout). When any of those fail, init_card() returns an error to
snd_probe(), which calls snd_card_free(card). Because ->private_free
is still NULL, card_free() never runs, the usb_get_dev() reference
is not dropped, and the struct usb_device leaks along with its
descriptor allocations and device_private.
syzbot reproduces this with a malformed UAC3 device whose only valid
altsetting is 0; init_card()'s usb_set_interface(usb_dev, 0, 1) call
fails with -EIO and triggers the leak.
Move the ->private_free assignment into create_card(), immediately
after usb_get_dev(), so that every error path reaching snd_card_free()
balances the reference. card_free()'s callees (snd_usb_caiaq_input_free,
free_urbs, kfree) already tolerate the partially-initialized state
because the chip private area is zero-initialized by snd_card_new().
Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
sound/usb/caiaq/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 51177ebfb8c6..f084a0f782ad 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -411,6 +411,7 @@ static int create_card(struct usb_device *usb_dev,
cdev = caiaqdev(card);
cdev->chip.dev = usb_get_dev(usb_dev);
+ card->private_free = card_free;
cdev->chip.card = card;
cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
le16_to_cpu(usb_dev->descriptor.idProduct));
@@ -500,7 +501,6 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
cdev->vendor_name, cdev->product_name, usbpath);
setup_card(cdev);
- card->private_free = card_free;
return 0;
err_kill_urb:
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Forwarded: [PATCH] usb: core: hub: fix memory leak in hub_port_connect
2026-04-25 2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
2026-04-25 6:36 ` Forwarded: [PATCH] usb: core: fix memory leak in usb_new_device() error path syzbot
2026-04-25 7:52 ` Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure syzbot
@ 2026-04-25 8:58 ` syzbot
2026-04-25 9:36 ` syzbot
` (3 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2026-04-25 8:58 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] usb: core: hub: fix memory leak in hub_port_connect
Author: souradiptodas6@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
master
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24960ba9caa9..2924ce770066 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5405,6 +5405,7 @@ static void hub_port_connect(struct usb_hub *hub, int
port1, u16 portstatus,
if (hcd->usb_phy && !hdev->parent)
usb_phy_notify_disconnect(hcd->usb_phy,
udev->speed);
usb_disconnect(&port_dev->child);
+ udev = NULL;
}
/* We can forget about a "removed" device when there's a physical
@@ -5582,6 +5583,7 @@ static void hub_port_connect(struct usb_hub *hub, int
port1, u16 portstatus,
goto loop_disable;
status = hub_power_remaining(hub);
+ udev = NULL;
if (status)
dev_dbg(hub->intfdev, "%dmA power budget left\n",
status);
@@ -5624,6 +5626,8 @@ static void hub_port_connect(struct usb_hub *hub, int
port1, u16 portstatus,
if (status != -ENOTCONN && status != -ENODEV)
hcd->driver->relinquish_port(hcd, port1);
}
+ if (udev)
+ usb_put_dev(udev);
}
/* Handle physical or logical connection change events.
^ permalink raw reply related [flat|nested] 17+ messages in thread* Forwarded: [PATCH] usb: core: hub: fix memory leak in hub_port_connect
2026-04-25 2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
` (2 preceding siblings ...)
2026-04-25 8:58 ` Forwarded: [PATCH] usb: core: hub: fix memory leak in hub_port_connect syzbot
@ 2026-04-25 9:36 ` syzbot
2026-04-25 12:54 ` Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure syzbot
` (2 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2026-04-25 9:36 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] usb: core: hub: fix memory leak in hub_port_connect
Author: souradiptodas6@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
---
drivers/usb/core/hub.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24960ba9caa9..2924ce770066 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5405,6 +5405,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
if (hcd->usb_phy && !hdev->parent)
usb_phy_notify_disconnect(hcd->usb_phy, udev->speed);
usb_disconnect(&port_dev->child);
+ udev = NULL;
}
/* We can forget about a "removed" device when there's a physical
@@ -5582,6 +5583,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
goto loop_disable;
status = hub_power_remaining(hub);
+ udev = NULL;
if (status)
dev_dbg(hub->intfdev, "%dmA power budget left\n", status);
@@ -5624,6 +5626,8 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
if (status != -ENOTCONN && status != -ENODEV)
hcd->driver->relinquish_port(hcd, port1);
}
+ if (udev)
+ usb_put_dev(udev);
}
/* Handle physical or logical connection change events.
--
2.52.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
2026-04-25 2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
` (3 preceding siblings ...)
2026-04-25 9:36 ` syzbot
@ 2026-04-25 12:54 ` syzbot
2026-04-25 14:43 ` syzbot
2026-04-27 11:40 ` [syzbot] [usb?] memory leak in hub_event (4) Oliver Neukum
6 siblings, 0 replies; 17+ messages in thread
From: syzbot @ 2026-04-25 12:54 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
create_card() takes a reference on the USB device with usb_get_dev()
and stores the matching usb_put_dev() in card_free(), which is
installed as the snd_card's ->private_free destructor.
However, ->private_free is only assigned near the end of init_card(),
after several failure points (usb_set_interface(), EP type checks,
usb_submit_urb(), the EP1_CMD_GET_DEVICE_INFO exchange, and its
timeout). When any of those fail, init_card() returns an error to
snd_probe(), which calls snd_card_free(card). Because ->private_free
is still NULL, card_free() never runs, the usb_get_dev() reference
is not dropped, and the struct usb_device leaks along with its
descriptor allocations and device_private.
syzbot reproduces this with a malformed UAC3 device whose only valid
altsetting is 0; init_card()'s usb_set_interface(usb_dev, 0, 1) call
fails with -EIO and triggers the leak.
Move the ->private_free assignment into create_card(), immediately
after usb_get_dev(), so that every error path reaching snd_card_free()
balances the reference. card_free()'s callees (snd_usb_caiaq_input_free,
free_urbs, kfree) already tolerate the partially-initialized state
because the chip private area is zero-initialized by snd_card_new().
Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
sound/usb/caiaq/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 51177ebfb8c6..f084a0f782ad 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -411,6 +411,7 @@ static int create_card(struct usb_device *usb_dev,
cdev = caiaqdev(card);
cdev->chip.dev = usb_get_dev(usb_dev);
+ card->private_free = card_free;
cdev->chip.card = card;
cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
le16_to_cpu(usb_dev->descriptor.idProduct));
@@ -500,7 +501,6 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
cdev->vendor_name, cdev->product_name, usbpath);
setup_card(cdev);
- card->private_free = card_free;
return 0;
err_kill_urb:
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
2026-04-25 2:12 [syzbot] [usb?] memory leak in hub_event (4) syzbot
` (4 preceding siblings ...)
2026-04-25 12:54 ` Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure syzbot
@ 2026-04-25 14:43 ` syzbot
2026-04-26 2:33 ` Hillf Danton
2026-04-27 11:40 ` [syzbot] [usb?] memory leak in hub_event (4) Oliver Neukum
6 siblings, 1 reply; 17+ messages in thread
From: syzbot @ 2026-04-25 14:43 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
create_card() takes a reference on the USB device with usb_get_dev()
and stores the matching usb_put_dev() in card_free(), which is
installed as the snd_card's ->private_free destructor.
However, ->private_free is only assigned near the end of init_card(),
after several failure points (usb_set_interface(), EP type checks,
usb_submit_urb(), the EP1_CMD_GET_DEVICE_INFO exchange, and its
timeout). When any of those fail, init_card() returns an error to
snd_probe(), which calls snd_card_free(card). Because ->private_free
is still NULL, card_free() never runs, the usb_get_dev() reference
is not dropped, and the struct usb_device leaks along with its
descriptor allocations and device_private.
syzbot reproduces this with a malformed UAC3 device whose only valid
altsetting is 0; init_card()'s usb_set_interface(usb_dev, 0, 1) call
fails with -EIO and triggers the leak.
Move the ->private_free assignment into create_card(), immediately
after usb_get_dev(), so that every error path reaching snd_card_free()
balances the reference. card_free()'s callees (snd_usb_caiaq_input_free,
free_urbs, kfree) already tolerate the partially-initialized state
because the chip private area is zero-initialized by snd_card_new().
Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
sound/usb/caiaq/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 8af0c04041ee..ad9f744b496b 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -423,6 +423,7 @@ static int create_card(struct usb_device *usb_dev,
cdev = caiaqdev(card);
cdev->chip.dev = usb_get_dev(usb_dev);
+ card->private_free = card_free;
cdev->chip.card = card;
cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
le16_to_cpu(usb_dev->descriptor.idProduct));
@@ -511,7 +512,6 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
scnprintf(card->longname, sizeof(card->longname), "%s %s (%s)",
cdev->vendor_name, cdev->product_name, usbpath);
- card->private_free = card_free;
err = setup_card(cdev);
if (err < 0)
return err;
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: Forwarded: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
2026-04-25 14:43 ` syzbot
@ 2026-04-26 2:33 ` Hillf Danton
0 siblings, 0 replies; 17+ messages in thread
From: Hillf Danton @ 2026-04-26 2:33 UTC (permalink / raw)
To: Deepanshu Kartikey; +Cc: syzbot, linux-kernel, syzkaller-bugs
> Date: Sat, 25 Apr 2026 07:43:17 -0700
> For archival purposes, forwarding an incoming command email to
> linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
>
> ***
>
> Subject: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
> Author: kartikey406@gmail.com
>
Deepanshu, can you please correctly fill your Cc list as required to
avoid this forwarded message which is a waste of net bandwidth?
> #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>
>
>
> create_card() takes a reference on the USB device with usb_get_dev()
> and stores the matching usb_put_dev() in card_free(), which is
> installed as the snd_card's ->private_free destructor.
>
> However, ->private_free is only assigned near the end of init_card(),
> after several failure points (usb_set_interface(), EP type checks,
> usb_submit_urb(), the EP1_CMD_GET_DEVICE_INFO exchange, and its
> timeout). When any of those fail, init_card() returns an error to
> snd_probe(), which calls snd_card_free(card). Because ->private_free
> is still NULL, card_free() never runs, the usb_get_dev() reference
> is not dropped, and the struct usb_device leaks along with its
> descriptor allocations and device_private.
>
> syzbot reproduces this with a malformed UAC3 device whose only valid
> altsetting is 0; init_card()'s usb_set_interface(usb_dev, 0, 1) call
> fails with -EIO and triggers the leak.
>
> Move the ->private_free assignment into create_card(), immediately
> after usb_get_dev(), so that every error path reaching snd_card_free()
> balances the reference. card_free()'s callees (snd_usb_caiaq_input_free,
> free_urbs, kfree) already tolerate the partially-initialized state
> because the chip private area is zero-initialized by snd_card_new().
>
> Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
> sound/usb/caiaq/device.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
> index 8af0c04041ee..ad9f744b496b 100644
> --- a/sound/usb/caiaq/device.c
> +++ b/sound/usb/caiaq/device.c
> @@ -423,6 +423,7 @@ static int create_card(struct usb_device *usb_dev,
>
> cdev = caiaqdev(card);
> cdev->chip.dev = usb_get_dev(usb_dev);
> + card->private_free = card_free;
> cdev->chip.card = card;
> cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
> le16_to_cpu(usb_dev->descriptor.idProduct));
> @@ -511,7 +512,6 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
> scnprintf(card->longname, sizeof(card->longname), "%s %s (%s)",
> cdev->vendor_name, cdev->product_name, usbpath);
>
> - card->private_free = card_free;
> err = setup_card(cdev);
> if (err < 0)
> return err;
> --
> 2.43.0
^ permalink raw reply [flat|nested] 17+ 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
` (5 preceding siblings ...)
2026-04-25 14:43 ` syzbot
@ 2026-04-27 11:40 ` Oliver Neukum
2026-04-27 12:37 ` syzbot
2026-04-27 14:19 ` Alan Stern
6 siblings, 2 replies; 17+ 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] 17+ messages in thread* Re: [syzbot] [usb?] memory leak in hub_event (4)
2026-04-27 11:40 ` [syzbot] [usb?] memory leak in hub_event (4) Oliver Neukum
@ 2026-04-27 12:37 ` syzbot
2026-04-27 14:19 ` Alan Stern
1 sibling, 0 replies; 17+ 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] 17+ messages in thread
* Re: [syzbot] [usb?] memory leak in hub_event (4)
2026-04-27 11:40 ` [syzbot] [usb?] memory leak in hub_event (4) Oliver Neukum
2026-04-27 12:37 ` syzbot
@ 2026-04-27 14:19 ` Alan Stern
1 sibling, 0 replies; 17+ 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] 17+ messages in thread