From: Alan Stern <stern@rowland.harvard.edu>
To: Oliver Neukum <oneukum@suse.com>
Cc: syzbot <syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com>,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [usb?] memory leak in hub_event (4)
Date: Mon, 27 Apr 2026 10:19:10 -0400 [thread overview]
Message-ID: <bb39abcf-aefd-42f6-b9e3-e576dbb5fc37@rowland.harvard.edu> (raw)
In-Reply-To: <9fea44a5-83de-41ed-9531-11e5d471dca4@suse.com>
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
next prev parent reply other threads:[~2026-04-27 14:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 2:12 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 ` 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
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
2026-04-27 12:37 ` syzbot
2026-04-27 14:19 ` Alan Stern [this message]
2026-04-28 11:33 ` Oliver Neukum
2026-04-28 15:12 ` Alan Stern
[not found] <20260425063629.59918-1-kartikey406@gmail.com>
2026-04-25 7:13 ` syzbot
[not found] <20260425075154.61497-1-kartikey406@gmail.com>
2026-04-25 8:41 ` syzbot
[not found] <CAKVbAB1UYCWwpZvmV05TuA_NU16YY6fEr5t0HUjuixVq_f5b+w@mail.gmail.com>
2026-04-25 9:51 ` syzbot
[not found] <20260425093612.30657-1-souradiptodas6@gmail.com>
2026-04-25 10:11 ` syzbot
[not found] <20260425125451.64534-1-kartikey406@gmail.com>
2026-04-25 14:09 ` syzbot
[not found] <20260425144309.67569-1-kartikey406@gmail.com>
2026-04-25 15:23 ` syzbot
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=bb39abcf-aefd-42f6-b9e3-e576dbb5fc37@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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®