From: sashiko-bot@kernel.org
To: "Igor Skalkin" <igor.skalkin@oss.qualcomm.com>
Cc: virtualization@lists.linux.dev, linux-usb@vger.kernel.org,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [RFC PATCH v2 7/7] virtio-usb: support a guest UDC name prefix from the bind event
Date: Tue, 01 Dec 2026 17:50:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-243906@kernel.org> (raw)
In-Reply-To: <6a4a46f93c39f4e6de4d81d62e41521b478772a9.1796144390.git.igor.skalkin@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] virtio-usb: missing pdev cleanup on BIND error in
virtio_usb_dc_event_process()
- [Low] virtio-usb: implicit trailing padding in struct
virtio_usb_dev_bind_event
--
commit 5fb457b7d6127d17ec3ed9354d4bbad3d36e472a
Author: Igor Skalkin <igor.skalkin@oss.qualcomm.com>
virtio-usb: support a guest UDC name prefix from the bind event
This commit allows the host backend to specify a custom UDC name prefix
in the bind event to name the port's UDC parent platform device and
gadget.
> diff --git a/drivers/usb/virtio_usb/device.c b/drivers/usb/virtio_usb/device.c
> index 0d44cb1dce6e4..d6fc1cc19713b 100644
> --- a/drivers/usb/virtio_usb/device.c
> +++ b/drivers/usb/virtio_usb/device.c
[ ... ]
> @@ -1594,7 +1610,8 @@ static void virtio_usb_dc_event_process(struct virtio_usb_event *event)
> break;
> }
> if (!vudc->pdev) {
> - rc = virtio_usb_dc_parent_create(vudc);
> + rc = virtio_usb_dc_parent_create(
> + vudc, bind_evt->udc_name_prefix);
> if (rc) {
> dev_err(&vusb->vdev->dev,
> "Failed to create UDC parent device\n");
> @@ -1603,8 +1620,18 @@ static void virtio_usb_dc_event_process(struct virtio_usb_event *event)
> break;
> }
> }
> - vudc->gadget.name =
> - kasprintf(GFP_KERNEL, "%s_%d", GADGET_NAME, port_id);
> + udc_prefix_len =
> + strnlen((const char *)bind_evt->udc_name_prefix,
> + VIRTIO_USB_UDC_NAME_PREFIX_MAX);
> + if (udc_prefix_len) {
> + vudc->gadget.name = kasprintf(
> + GFP_KERNEL, "%.*s_p%d", (int)udc_prefix_len,
> + (const char *)bind_evt->udc_name_prefix,
> + port_id);
> + } else {
> + vudc->gadget.name = kasprintf(GFP_KERNEL, "%s_%d",
> + GADGET_NAME, port_id);
> + }
> if (!vudc->gadget.name) {
> rc = -ENOMEM;
> kfree(vudc->veps);
> @@ -1627,7 +1654,6 @@ static void virtio_usb_dc_event_process(struct virtio_usb_event *event)
> break;
> }
>
> - //vudc->gadget.dev.init_name = gadget_name;
> vudc->gadget.dev.parent = &vudc->pdev->dev;
> rc = usb_add_gadget_udc(&vudc->pdev->dev, &vudc->gadget);
> if (rc) {
[Severity: Medium]
Does a failure in kasprintf() or usb_add_gadget_udc() leave vudc->pdev
registered with the failed bind event's udc_name_prefix?
Neither error path unregisters vudc->pdev or clears it to NULL. Because
virtio_usb_dc_parent_create() is only called when vudc->pdev is NULL, a
later VIRTIO_USB_EVT_DEV_BIND event will skip creating the parent device
and reuse the stale vudc->pdev name (which usb_add_gadget() also uses as
the UDC class device name in /sys/class/udc/) while formatting
vudc->gadget.name with the new prefix.
> diff --git a/include/uapi/linux/virtio_usb.h b/include/uapi/linux/virtio_usb.h
> index 238052b4f0a98..d3199cbd7d100 100644
> --- a/include/uapi/linux/virtio_usb.h
> +++ b/include/uapi/linux/virtio_usb.h
> @@ -193,6 +193,8 @@ struct virtio_usb_dev_ep_info {
> #define VIRTIO_USB_EVT_DEV_RESUME 5
> #define VIRTIO_USB_EVT_DEV_UNBIND 6
>
> +#define VIRTIO_USB_UDC_NAME_PREFIX_MAX 64
> +
> struct virtio_usb_dev_event {
> __le32 code; /* VIRTIO_USB_EVT_DEV_XXX */
> __le16 port; /* Device ID */
> @@ -204,7 +206,7 @@ struct virtio_usb_dev_bind_event {
> __le32 code; /* VIRTIO_USB_EVT_DEV_BIND */
> __le16 port; /* Device ID */
> __u8 max_speed; /* enum usb_device_speed */
> - __u8 padding[9];
> + __u8 udc_name_prefix[VIRTIO_USB_UDC_NAME_PREFIX_MAX];
> };
[Severity: Low]
Does struct virtio_usb_dev_bind_event have 1 byte of implicit trailing
compiler padding?
The declared fields sum to 71 bytes inside a 4-byte-aligned UAPI struct,
so sizeof(struct virtio_usb_dev_bind_event) is 72 bytes while
virtio_usb_dc_event_padding_ok() assumes VIRTIO_USB_EVT_DEV_BIND has no
padding bytes to validate.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796144390.git.igor.skalkin@oss.qualcomm.com?part=7
next prev parent reply other threads:[~2026-12-01 17:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 16:08 [PATCH 0/8] virtio-usb: add dual-role virtio USB driver Igor Skalkin
2026-09-24 16:09 ` [PATCH 1/8] virtio-usb: add protocol header and skeleton dual-role driver Igor Skalkin
2026-09-25 5:14 ` Greg Kroah-Hartman
2026-09-28 14:19 ` Igor Skalkin
2026-09-25 5:21 ` Greg Kroah-Hartman
2026-09-28 14:14 ` Igor Skalkin
2026-09-24 16:09 ` [PATCH 2/8] virtio-usb: add host role (USB Host Controller) support Igor Skalkin
2026-09-25 5:18 ` Greg Kroah-Hartman
2026-09-28 14:01 ` Igor Skalkin
2026-09-24 16:09 ` [PATCH 3/8] virtio-usb: add device role (USB Device " Igor Skalkin
2026-09-24 16:09 ` [PATCH 4/8] virtio-usb: add OTG role query support Igor Skalkin
2026-09-24 16:09 ` [PATCH 5/8] virtio-usb: add USB On-The-Go role-switching support Igor Skalkin
2026-09-24 16:09 ` [PATCH 6/8] virtio-usb: rework endpoint lifecycle to an async split-phase state machine Igor Skalkin
2026-09-24 16:09 ` [PATCH 7/8] virtio-usb: add SuperSpeed device-role support Igor Skalkin
2026-09-24 16:09 ` [PATCH 8/8] virtio-usb: support a guest UDC name prefix from the bind event Igor Skalkin
2026-09-25 5:17 ` [PATCH 0/8] virtio-usb: add dual-role virtio USB driver Greg Kroah-Hartman
2026-09-28 13:55 ` Igor Skalkin
2026-09-28 14:44 ` Greg Kroah-Hartman
2026-09-28 15:56 ` Igor Skalkin
2026-09-28 16:10 ` Greg Kroah-Hartman
2026-09-29 9:47 ` Michael S. Tsirkin
2026-09-29 16:01 ` Greg Kroah-Hartman
2026-09-29 19:02 ` Vasilii Ianikeev
2026-09-29 19:58 ` Vasilii Ianikeev
2026-12-01 17:35 ` [RFC PATCH v2 0/7] " Igor Skalkin
2026-12-01 17:35 ` [RFC PATCH v2 1/7] uapi: virtio_ids: reserve ID for virtio USB device Igor Skalkin
2026-12-01 17:35 ` [RFC PATCH v2 2/7] virtio-usb: add protocol header and skeleton dual-role driver Igor Skalkin
2026-12-01 17:52 ` sashiko-bot
2026-12-01 17:35 ` [RFC PATCH v2 3/7] virtio-usb: add host role (USB Host Controller) support Igor Skalkin
2026-12-01 17:35 ` [RFC PATCH v2 4/7] virtio-usb: add device role (USB Device " Igor Skalkin
2026-12-01 17:35 ` [RFC PATCH v2 5/7] virtio-usb: add per-port role query support Igor Skalkin
2026-12-01 17:54 ` sashiko-bot
2026-12-01 17:35 ` [RFC PATCH v2 6/7] virtio-usb: add host/device role switch support Igor Skalkin
2026-12-01 18:00 ` sashiko-bot
2026-12-01 17:35 ` [RFC PATCH v2 7/7] virtio-usb: support a guest UDC name prefix from the bind event Igor Skalkin
2026-12-01 17:50 ` sashiko-bot [this message]
2026-12-01 17:49 ` [RFC PATCH v2 0/7] virtio-usb: add dual-role virtio USB driver Michael S. Tsirkin
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=sashiko-outbox-243906@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=igor.skalkin@oss.qualcomm.com \
--cc=linux-usb@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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