* Re: [PATCH] usb: gadget: uvc: fix lockdep deadlock in configfs attributes
[not found] <20261117184104.580959-1-timo.joannin@gmail.com>
@ 2026-11-17 18:41 ` syzbot
0 siblings, 0 replies; only message in thread
From: syzbot @ 2026-11-17 18:41 UTC (permalink / raw)
To: timo.joannin; +Cc: timo.joannin, linux-kernel, syzkaller-bugs
> #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
Patch testing via #syz test is temporarily disabled.
See https://github.com/google/syzkaller/issues/8122 for details.
>
> Patch to resolve the lockdep warning in uvc_configfs.
>
> Signed-off-by: Timo Joannin <timo.joannin@gmail.com>
> ---
> drivers/usb/gadget/function/uvc_configfs.c | 48 ++++++++++++++--------
> drivers/usb/gadget/function/uvc_configfs.h | 6 +++
> 2 files changed, 38 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
> index 70a1415ea401..0be29022161a 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -269,11 +269,16 @@ static struct config_item *uvcg_control_header_make(struct config_group *group,
> const char *name)
> {
> struct uvcg_control_header *h;
> + struct f_uvc_opts *opts;
>
> h = kzalloc_obj(*h);
> if (!h)
> return ERR_PTR(-ENOMEM);
>
> + // find opts once
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
> + h->opts = opts;
> +
> h->desc.bLength = UVC_DT_HEADER_SIZE(1);
> h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> h->desc.bDescriptorSubType = UVC_VC_HEADER;
> @@ -1007,19 +1012,11 @@ UVC_ATTR(uvcg_extension_, guid_extension_code, guidExtensionCode);
> static ssize_t uvcg_extension_ba_source_id_show(struct config_item *item,
> char *page)
> {
> - struct config_group *group = to_config_group(item->ci_parent);
> - struct mutex *su_mutex = &group->cg_subsys->su_mutex;
> struct uvcg_extension *xu = to_uvcg_extension(item);
> - struct config_item *opts_item;
> - struct f_uvc_opts *opts;
> + struct f_uvc_opts *opts = xu->opts;
> char *pg = page;
> int ret, i;
>
> - mutex_lock(su_mutex);
> -
> - opts_item = item->ci_parent->ci_parent->ci_parent;
> - opts = to_f_uvc_opts(opts_item);
> -
> mutex_lock(&opts->lock);
> for (ret = 0, i = 0; i < xu->desc.bNrInPins; ++i) {
> ret += sprintf(pg, "%u\n", xu->desc.baSourceID[i]);
> @@ -1027,8 +1024,6 @@ static ssize_t uvcg_extension_ba_source_id_show(struct config_item *item,
> }
> mutex_unlock(&opts->lock);
>
> - mutex_unlock(su_mutex);
> -
> return ret;
> }
>
> @@ -1270,13 +1265,14 @@ static struct config_item *uvcg_extension_make(struct config_group *group, const
> struct uvcg_extension *xu;
> struct f_uvc_opts *opts;
>
> - opts_item = group->cg_item.ci_parent->ci_parent;
> - opts = to_f_uvc_opts(opts_item);
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
>
> xu = kzalloc_obj(*xu);
> if (!xu)
> return ERR_PTR(-ENOMEM);
>
> + xu->opts = opts;
> +
> xu->desc.bLength = UVC_DT_EXTENSION_UNIT_SIZE(0, 0);
> xu->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> xu->desc.bDescriptorSubType = UVC_VC_EXTENSION_UNIT;
> @@ -1898,12 +1894,17 @@ static struct config_item
> *uvcg_streaming_header_make(struct config_group *group, const char *name)
> {
> struct uvcg_streaming_header *h;
> + struct f_uvc_opts *opts;
>
> h = kzalloc_obj(*h);
> if (!h)
> return ERR_PTR(-ENOMEM);
>
> INIT_LIST_HEAD(&h->formats);
> +
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
> + h->opts = opts;
> +
> h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> h->desc.bDescriptorSubType = UVC_VS_INPUT_HEADER;
> h->desc.bTerminalLink = 3;
> @@ -2167,6 +2168,9 @@ static struct config_item *uvcg_frame_make(struct config_group *group,
> if (!h)
> return ERR_PTR(-ENOMEM);
>
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent->ci_parent);
> + h->opts = opts;
> +
> h->frame.b_descriptor_type = USB_DT_CS_INTERFACE;
> h->frame.b_frame_index = 1;
> h->frame.w_width = 640;
> @@ -2177,9 +2181,6 @@ static struct config_item *uvcg_frame_make(struct config_group *group,
> h->frame.dw_default_frame_interval = 666666;
> h->frame.dw_bytes_perline = 0;
>
> - opts_item = group->cg_item.ci_parent->ci_parent->ci_parent;
> - opts = to_f_uvc_opts(opts_item);
> -
> mutex_lock(&opts->lock);
> fmt = to_uvcg_format(&group->cg_item);
> if (fmt->type == UVCG_UNCOMPRESSED) {
> @@ -2477,6 +2478,7 @@ static struct config_group *uvcg_uncompressed_make(struct config_group *group,
> struct uvcg_color_matching *color_match;
> struct config_item *streaming;
> struct uvcg_uncompressed *h;
> + struct f_uvc_opts *opts;
>
> streaming = group->cg_item.ci_parent;
> color_match = uvcg_format_get_default_color_match(streaming);
> @@ -2487,6 +2489,9 @@ static struct config_group *uvcg_uncompressed_make(struct config_group *group,
> if (!h)
> return ERR_PTR(-ENOMEM);
>
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
> + h->opts = opts;
> +
> h->desc.bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
> h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> h->desc.bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED;
> @@ -2669,6 +2674,7 @@ static struct config_group *uvcg_mjpeg_make(struct config_group *group,
> struct uvcg_color_matching *color_match;
> struct config_item *streaming;
> struct uvcg_mjpeg *h;
> + struct f_uvc_opts *opts;
>
> streaming = group->cg_item.ci_parent;
> color_match = uvcg_format_get_default_color_match(streaming);
> @@ -2679,6 +2685,9 @@ static struct config_group *uvcg_mjpeg_make(struct config_group *group,
> if (!h)
> return ERR_PTR(-ENOMEM);
>
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
> + h->opts = opts;
> +
> h->desc.bLength = UVC_DT_FORMAT_MJPEG_SIZE;
> h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> h->desc.bDescriptorSubType = UVC_VS_FORMAT_MJPEG;
> @@ -2930,6 +2939,9 @@ static struct config_group *uvcg_framebased_make(struct config_group *group,
> if (!h)
> return ERR_PTR(-ENOMEM);
>
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
> + h->opts = opts;
> +
> h->desc.bLength = UVC_DT_FORMAT_FRAMEBASED_SIZE;
> h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> h->desc.bDescriptorSubType = UVC_VS_FORMAT_FRAME_BASED;
> @@ -3074,11 +3086,15 @@ static struct config_group *uvcg_color_matching_make(struct config_group *group,
> const char *name)
> {
> struct uvcg_color_matching *color_match;
> + struct f_uvc_opts *opts;
>
> color_match = kzalloc_obj(*color_match);
> if (!color_match)
> return ERR_PTR(-ENOMEM);
>
> + opts = to_f_uvc_opts(group->cg_item.ci_parent->ci_parent);
> + color_match->opts = opts;
> +
> color_match->desc.bLength = UVC_DT_COLOR_MATCHING_SIZE;
> color_match->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> color_match->desc.bDescriptorSubType = UVC_VS_COLORFORMAT;
> diff --git a/drivers/usb/gadget/function/uvc_configfs.h b/drivers/usb/gadget/function/uvc_configfs.h
> index 9391614135e9..132a11ef57f3 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.h
> +++ b/drivers/usb/gadget/function/uvc_configfs.h
> @@ -30,6 +30,7 @@ struct uvcg_control_header {
> struct config_item item;
> struct UVC_HEADER_DESCRIPTOR(1) desc;
> unsigned linked;
> + struct f_uvc_opts *opts; /* pointer to top level f_uvc_opts struct */
> };
>
> static inline struct uvcg_control_header *to_uvcg_control_header(struct config_item *item)
> @@ -41,6 +42,7 @@ struct uvcg_color_matching {
> struct config_group group;
> struct uvc_color_matching_descriptor desc;
> unsigned int refcnt;
> + struct f_uvc_opts *opts;
> };
>
> #define to_uvcg_color_matching(group_ptr) \
> @@ -60,6 +62,7 @@ struct uvcg_format {
> unsigned num_frames;
> __u8 bmaControls[UVCG_STREAMING_CONTROL_SIZE];
> struct uvcg_color_matching *color_matching;
> + struct f_uvc_opts *opts;
> };
>
> struct uvcg_format_ptr {
> @@ -77,6 +80,7 @@ struct uvcg_streaming_header {
> unsigned linked;
> struct list_head formats;
> unsigned num_fmt;
> + struct f_uvc_opts *opts;
>
> /* Must be last --ends in a flexible-array member. */
> struct uvc_input_header_descriptor desc;
> @@ -95,6 +99,7 @@ struct uvcg_frame_ptr {
> struct uvcg_frame {
> struct config_item item;
> enum uvcg_format_type fmt_type;
> + struct f_uvc_opts *opts;
> struct {
> u8 b_length;
> u8 b_descriptor_type;
> @@ -182,6 +187,7 @@ struct uvcg_extension {
> struct config_item item;
> struct list_head list;
> u8 string_descriptor_index;
> + struct f_uvc_opts *opts;
> struct uvcg_extension_unit_descriptor desc;
> };
>
> --
> 2.56.1
>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 18:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20261117184104.580959-1-timo.joannin@gmail.com>
2026-11-17 18:41 ` [PATCH] usb: gadget: uvc: fix lockdep deadlock in configfs attributes syzbot
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®