From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796147410; b=V5b45inaJXsU7y01UsaV4GnCDTsXdvNtWOf+AK9yPbkl3Cr7Tst/PvqLhRQLNwvR1pNU yJJK1A+SjsLG8uvStQ7T+IisHddqHCzu6arNIg68W73MJU5CAh3TQJqJXnrnQ2pPv2Qqu fgfxcnmN3FY54lhD8jk1WkAcxj8kfVE3/sbSRSHatvsGr/azVjUC0wFnFPtWLy3KOvGoc kGZmLOwZxSDCoAMOYR19cYcp7W8Y6Y1+TqkWpb99oizpvhAfwRVn4PTJn+SWxRCqHpgdK iTjOAxpMVhMVFGd1K+9mXr4cL5nzhPHg0A6zmA/lGAjFmJJx6Y5akEoobwf2x+ySk9g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796147410; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=VSYPkp62x6phopJQvKrw7LU9Z407l726oq+PjHxEMF0=; b=s6EkeZ03fgJdEiPgRr/xfglGWjeX36/NHpEYNR+s9nGV0xUObe62kF+1w54jaxxOfmXf IVRkzIZ5NlZJlJx3QMDY4Dv8Bcmf19pBoATdyMFZpj9sY77AH7bJ3tFxZ5QFZtx2ycLz6 JI16Jm1YxyrBODWyGkfUVBGdqcpxMTEKNHKbip8pfabqBkkyL5TDrGQj8xAbdCxFh9qY0 7XhaQ8bleNSW7eXjldXHFQHm0iPOVqetIekUx/GI7DPhCpK38Vru14zb3zb35sXZEJ+XV Nt7CYfKwvwGuOCvGW4UQ2wN17uuHWEWrKf2IyD5bjf+5pS+/hMEePwHU0MF1E13iH/A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XPPvef8w; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9F80606A320; Tue, 1 Dec 2026 17:50:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XPPvef8w Received: by smtp.kernel.org (Postfix) with ESMTPSA id 032471F000C1; Tue, 1 Dec 2026 17:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796147410; bh=VSYPkp62x6phopJQvKrw7LU9Z407l726oq+PjHxEMF0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=XPPvef8wLBrsVmPGviWIcuihqWvYcIe3YPvr9BVuAu6EKnwXvSoP35jOfObe3kRnT vGUkTo+sYs1Ld2G2DyvtMUGgmhOMKbDS4AmBR/Z3l8GxbiQLfT8IME1B9jYHSCfFfy yvpZS17rRHUgZgkApe8IaoOeqCcQqAz/xRRYvgK3xWg4fZrzMyzotxTlPmGkOXpKZQ EtPJ1JmQCb3xp7j8KokXdwuwtD+Q9z8arsPHeHE2wuLkN2sGCJMvfvx7OiRmXIvtTH pzNnuO1bGR/k0Sfe3zmQzJKmCo8qnl64+DonVa/VqYKMY//eYin4OwhjO/7M6ENVnC LDlgYRPcnYKlw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v2 7/7] virtio-usb: support a guest UDC name prefix from the bind event Reply-To: sashiko-reviews@lists.linux.dev To: "Igor Skalkin" Cc: virtualization@lists.linux.dev, linux-usb@vger.kernel.org, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <6a4a46f93c39f4e6de4d81d62e41521b478772a9.1796144390.git.igor.skalkin@oss.qualcomm.com> References: <20260924160907.145405-1-igor.skalkin@oss.qualcomm.com> <6a4a46f93c39f4e6de4d81d62e41521b478772a9.1796144390.git.igor.skalkin@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 17:50:09 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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/dev= ice.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 virt= io_usb_event *event) > break; > } > if (!vudc->pdev) { > - rc =3D virtio_usb_dc_parent_create(vudc); > + rc =3D 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 vir= tio_usb_event *event) > break; > } > } > - vudc->gadget.name =3D > - kasprintf(GFP_KERNEL, "%s_%d", GADGET_NAME, port_id); > + udc_prefix_len =3D > + strnlen((const char *)bind_evt->udc_name_prefix, > + VIRTIO_USB_UDC_NAME_PREFIX_MAX); > + if (udc_prefix_len) { > + vudc->gadget.name =3D kasprintf( > + GFP_KERNEL, "%.*s_p%d", (int)udc_prefix_len, > + (const char *)bind_evt->udc_name_prefix, > + port_id); > + } else { > + vudc->gadget.name =3D kasprintf(GFP_KERNEL, "%s_%d", > + GADGET_NAME, port_id); > + } > if (!vudc->gadget.name) { > rc =3D -ENOMEM; > kfree(vudc->veps); > @@ -1627,7 +1654,6 @@ static void virtio_usb_dc_event_process(struct virt= io_usb_event *event) > break; > } > =20 > - //vudc->gadget.dev.init_name =3D gadget_name; > vudc->gadget.dev.parent =3D &vudc->pdev->dev; > rc =3D 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 > =20 > +#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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796144390.gi= t.igor.skalkin@oss.qualcomm.com?part=3D7