Linux USB
 help / color / mirror / Atom feed
* error handling in stub_recv_cmd_submit()
@ 2026-10-08 13:47 Oliver Neukum
  0 siblings, 0 replies; only message in thread
From: Oliver Neukum @ 2026-10-08 13:47 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan; +Cc: Hongren Zheng, USB list

[-- Attachment #1: Type: text/plain, Size: 300 bytes --]

Hi,

I was looking at the way, errors are handled in that function
and I saw no way the different errors were reacted to makes sense.
Some errors trigger an error condition set by usbip_event_add()
while others do not. It would seem to me that all errors need
to trigger an event.

	Regards
		Oliver

[-- Attachment #2: 0001-b-usbip-error-handling-in-stub_recv_cmd_submit.patch --]
[-- Type: text/x-patch, Size: 2056 bytes --]

From e34bf9253e0b39dba20ba1d5f1902649d35c0251 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 8 Oct 2026 15:45:22 +0200
Subject: [PATCH] b: usbip: error handling in stub_recv_cmd_submit

If an error happens an appropriate event must be triggered.
Centralize trigger events to ensure that no error conditions
are lost and remain unhandled.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/usbip/stub_rx.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
index 0ccc05b76c5a..bc35ccb022ac 100644
--- a/drivers/usb/usbip/stub_rx.c
+++ b/drivers/usb/usbip/stub_rx.c
@@ -479,7 +479,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 	int is_tweaked;
 
 	if (pipe == -1)
-		return;
+		goto err_malloc;
 
 	/*
 	 * Smatch reported the error case where use_sg is true and buf_len is 0.
@@ -488,7 +488,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 	 */
 	priv = stub_priv_alloc(sdev, pdu);
 	if (!priv)
-		return;
+		goto err_malloc;
 
 	buf_len = (unsigned long long)pdu->u.cmd_submit.transfer_buffer_length;
 
@@ -560,10 +560,8 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 		/* copy urb setup packet */
 		priv->urbs[0]->setup_packet = kmemdup(&pdu->u.cmd_submit.setup,
 					8, GFP_KERNEL);
-		if (!priv->urbs[0]->setup_packet) {
-			usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
-			return;
-		}
+		if (!priv->urbs[0]->setup_packet)
+			goto err_urb;
 
 		usbip_pack_pdu(pdu, priv->urbs[0], USBIP_CMD_SUBMIT, 0);
 	} else {
@@ -599,10 +597,16 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 	}
 
 	if (stub_recv_xbuff(ud, priv) < 0)
+		/* error condition already set */
 		return;
 
-	if (usbip_recv_iso(ud, priv->urbs[0]) < 0)
-		return;
+	ret = usbip_recv_iso(ud, priv->urbs[0]);
+	if (ret < 0) {
+		if (ret != -EPIPE)
+			goto err_urb;
+		else
+			return;
+	}
 
 	/* urb is now ready to submit */
 	for (i = 0; i < priv->num_urbs; i++) {
-- 
2.55.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-08 13:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 13:47 error handling in stub_recv_cmd_submit() Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox