All of lore.kernel.org
 help / color / mirror / Atom feed
* PATCH 1/1: greybus/usb: handle unspecified lengths in hub_control
@ 2026-02-11 22:02 Jose A. Perez de Azpillaga
  2026-02-12 11:43 ` [greybus-dev] " Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-02-11 22:02 UTC (permalink / raw)
  To: greybus-dev, linux-kernel

From 1e099b581fe475905509b9d600015ea2500b8cf8 Mon Sep 17 00:00:00 2001
From: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>
Date: Wed, 11 Feb 2026 22:54:40 +0100
Subject: [PATCH] greybus/usb: handle unspecified lengths in hub_control

Fixes the FIXME in hub_control where response length was not handled correctly.

Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
---
 drivers/staging/greybus/usb.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c
index 475f24f20cd4..f5f5a4863ddc 100644
--- a/drivers/staging/greybus/usb.c
+++ b/drivers/staging/greybus/usb.c
@@ -105,8 +105,10 @@ static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
 	size_t response_size;
 	int ret;
 
-	/* FIXME: handle unspecified lengths */
-	response_size = sizeof(*response) + wLength;
+	/* Calculate expected response size */
+	response_size = sizeof(*response);
+	if (wLength)
+		response_size += wLength;
 
 	operation = gb_operation_create(dev->connection,
 					GB_USB_TYPE_HUB_CONTROL,
@@ -127,9 +129,13 @@ static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
 		goto out;
 
 	if (wLength) {
-		/* Greybus core has verified response size */
-		response = operation->response->payload;
-		memcpy(buf, response->buf, wLength);
+		size_t actual_size = operation->response->payload_size - sizeof(*response);
+		size_t copy_size = min(wLength, actual_size);
+
+		if (copy_size) {
+			response = operation->response->payload;
+			memcpy(buf, response->buf, copy_size);
+		}
 	}
 out:
 	gb_operation_put(operation);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-12 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 22:02 PATCH 1/1: greybus/usb: handle unspecified lengths in hub_control Jose A. Perez de Azpillaga
2026-02-12 11:43 ` [greybus-dev] " Greg KH
2026-02-12 18:23   ` [PATCH v2] " Jose A. Perez de Azpillaga

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.