2022-05-16 20:21:03

by Wang Cheng

[permalink] [raw]
Subject: [PATCH v4 0/3] staging: rtl8712: fix KMSAN: uninit-value in r871xu_drv_init

Changelog v3->v4:
- Update commit messages.

v3: https://lore.kernel.org/all/[email protected]/

Wang Cheng (3):
staging: rtl8712: add error handler in r8712_usbctrl_vendorreq()
staging: rtl8712: fix uninit-value in usb_read8() and friends
staging: rtl8712: fix uninit-value in r871xu_drv_init()

drivers/staging/rtl8712/usb_intf.c | 6 +++---
drivers/staging/rtl8712/usb_ops.c | 27 ++++++++++++++++---------
drivers/staging/rtl8712/usb_ops_linux.c | 21 ++++++++++++-------
3 files changed, 35 insertions(+), 19 deletions(-)

--
2.33.1



2022-05-17 03:14:57

by Wang Cheng

[permalink] [raw]
Subject: [PATCH v4 1/3] staging: rtl8712: add error handler in r8712_usbctrl_vendorreq()

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 <[email protected]>
---
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