[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_C77B782B54A36A4930DC5CD7666E19801D0A@qq.com>
Date: Sat, 22 Apr 2023 18:04:46 +0800
From: Zhang Shurong <zhang_shurong@...mail.com>
To: tony0620emma@...il.com
Cc: kvalo@...nel.org, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, linux-wireless@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Zhang Shurong <zhang_shurong@...mail.com>
Subject: [PATCH 02/10] wifi: rtw88: fix incorrect error codes in rtw_debugfs_set_read_reg
If there is a failure during copy_from_user or user-provided data
buffer is invalid, rtw_debugfs_set_read_reg should return negative
error code instead of a positive value count.
Fix this bug by returning correct error code.
Signed-off-by: Zhang Shurong <zhang_shurong@...mail.com>
---
drivers/net/wireless/realtek/rtw88/debug.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
index bc41c5a7acaf..3c3350bb2855 100644
--- a/drivers/net/wireless/realtek/rtw88/debug.c
+++ b/drivers/net/wireless/realtek/rtw88/debug.c
@@ -201,13 +201,16 @@ static ssize_t rtw_debugfs_set_read_reg(struct file *filp,
char tmp[32 + 1];
u32 addr, len;
int num;
+ int ret;
- rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
+ ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
+ if (ret < 0)
+ return ret;
num = sscanf(tmp, "%x %x", &addr, &len);
if (num != 2)
- return count;
+ return -EINVAL;
if (len != 1 && len != 2 && len != 4) {
rtw_warn(rtwdev, "read reg setting wrong len\n");
--
2.40.0
Powered by blists - more mailing lists