From: Wang Cheng <wanngchenng@gmail.com>
To: dan.carpenter@oracle.com, paskripkin@gmail.com
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/3] staging: rtl8712: add error handler in r8712_usbctrl_vendorreq()
Date: Fri, 6 May 2022 20:01:44 +0800 [thread overview]
Message-ID: <e33ea53d36c422fbe7eabec5bd9eecb0ebce1bc5.1651833575.git.wanngchenng@gmail.com> (raw)
In-Reply-To: <cover.1651833575.git.wanngchenng@gmail.com>
When 'status' returned from usb_control_msg() is not equal to 'len',
that usb_control_msg() is on partial failure, r8712_usbctrl_vendorreq()
will treat partial reads as success.
Signed-off-by: Wang Cheng <wanngchenng@gmail.com>
---
drivers/staging/rtl8712/usb_ops_linux.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c
index f984a5ab2c6f..b2181e1e2d38 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -495,14 +495,21 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
}
status = usb_control_msg(udev, pipe, request, reqtype, value, index,
pIo_buf, len, 500);
- if (status > 0) { /* Success this control transfer. */
- if (requesttype == 0x01) {
- /* For Control read transfer, we have to copy the read
- * data from pIo_buf to pdata.
- */
- memcpy(pdata, pIo_buf, status);
- }
+ if (status < 0)
+ goto free;
+ if (status != len) {
+ status = -EREMOTEIO;
+ goto free;
+ }
+ /* Success this control transfer. */
+ if (requesttype == 0x01) {
+ /* For Control read transfer, we have to copy the read
+ * data from pIo_buf to pdata.
+ */
+ memcpy(pdata, pIo_buf, status);
}
+
+free:
kfree(palloc_buf);
return status;
}
--
2.33.1
next prev parent reply other threads:[~2022-05-06 12:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 11:59 [PATCH v3 0/3] staging: rtl8712: fix KMSAN: uninit-value in r871xu_drv_init Wang Cheng
2022-05-06 11:59 ` [PATCH v3 1/3] staging: rtl8712: fix uninit-value in usb_read8() and friends Wang Cheng
2022-05-06 12:12 ` Pavel Skripkin
2022-05-10 3:34 ` Wang Cheng
2022-05-06 11:59 ` [PATCH v3 2/3] staging: rtl8712: fix uninit-value in r871xu_drv_init() Wang Cheng
2022-05-06 12:27 ` Pavel Skripkin
2022-05-06 12:35 ` Pavel Skripkin
2022-05-06 12:01 ` Wang Cheng [this message]
2022-05-06 12:13 ` [PATCH v3 3/3] staging: rtl8712: add error handler in r8712_usbctrl_vendorreq() Pavel Skripkin
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=e33ea53d36c422fbe7eabec5bd9eecb0ebce1bc5.1651833575.git.wanngchenng@gmail.com \
--to=wanngchenng@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=paskripkin@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;
as well as URLs for NNTP newsgroup(s).