From: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
To: gregkh@linuxfoundation.org
Cc: dan.scally@ideasonboard.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Shuangpeng Bai <shuangpeng.kernel@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] usb: gadget: uvc: fix use-after-free in extension drop
Date: Fri, 14 Aug 2026 18:22:54 -0400 [thread overview]
Message-ID: <20260814222254.4104235-1-shuangpeng.kernel@gmail.com> (raw)
uvcg_extension_make() adds a newly allocated extension unit to the
extension_units list before configfs attaches the item. If attaching the
item fails, configfs unlinks it and invokes the drop callback during error
cleanup.
On this path, config_item_put() in uvcg_extension_drop() can drop the
last reference and free the extension unit. The subsequent list_del() and
descriptor cleanup then access the freed object.
Remove the extension unit from the list and free its descriptors while the
config item still holds the object alive. Drop the config item reference
only after all accesses to the extension unit are complete.
Fixes: 0525210c9840 ("usb: gadget: uvc: Allow definition of XUs in configfs")
Cc: stable@vger.kernel.org
Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
---
drivers/usb/gadget/function/uvc_configfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
index 70a1415ea401..86facba5109f 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -1256,12 +1256,13 @@ static void uvcg_extension_drop(struct config_group *group, struct config_item *
mutex_lock(&opts->lock);
- config_item_put(item);
list_del(&xu->list);
kfree(xu->desc.baSourceID);
kfree(xu->desc.bmControls);
mutex_unlock(&opts->lock);
+
+ config_item_put(item);
}
static struct config_item *uvcg_extension_make(struct config_group *group, const char *name)
--
2.43.0
reply other threads:[~2026-08-14 22:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260814222254.4104235-1-shuangpeng.kernel@gmail.com \
--to=shuangpeng.kernel@gmail.com \
--cc=dan.scally@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox