Linux USB
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Valentina Manea <valentina.manea.m@gmail.com>,
	Shuah Khan <shuah@kernel.org>
Cc: Hongren Zheng <i@zenithal.me>, USB list <linux-usb@vger.kernel.org>
Subject: error handling in stub_recv_cmd_submit()
Date: Thu, 8 Oct 2026 15:47:20 +0200	[thread overview]
Message-ID: <7d476c99-afac-4257-9252-a71ff584b726@suse.com> (raw)

[-- 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


                 reply	other threads:[~2026-10-08 13:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=7d476c99-afac-4257-9252-a71ff584b726@suse.com \
    --to=oneukum@suse.com \
    --cc=i@zenithal.me \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.com \
    /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