2023-07-15 13:47:40

by Zhang Shurong

[permalink] [raw]
Subject: [PATCH v4] wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()

If there is a failure during kstrtobool_from_user()
rtw89_debug_priv_btc_manual_set should return a negative error code
instead of returning the count directly.

Fix this bug by returning an error code instead of a count after
a failed call of the function "kstrtobool_from_user". Moreover
I omitted the label "out" with this source code correction.

Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Signed-off-by: Zhang Shurong <[email protected]>
---
Changes in v2:
- Corrected the format of this patch
- Used variable ret instead of goto out
Changes in v3:
- Improved change description
Changes in v4:
- Improved change description

drivers/net/wireless/realtek/rtw89/debug.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/debug.c b/drivers/net/wireless/realtek/rtw89/debug.c
index a4bbac916e22..ce5a9ac08145 100644
--- a/drivers/net/wireless/realtek/rtw89/debug.c
+++ b/drivers/net/wireless/realtek/rtw89/debug.c
@@ -3193,12 +3193,14 @@ static ssize_t rtw89_debug_priv_btc_manual_set(struct file *filp,
struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
struct rtw89_btc *btc = &rtwdev->btc;
bool btc_manual;
+ int ret;

- if (kstrtobool_from_user(user_buf, count, &btc_manual))
- goto out;
+ ret = kstrtobool_from_user(user_buf, count, &btc_manual);
+ if (ret)
+ return ret;

btc->ctrl.manual = btc_manual;
-out:
+
return count;
}

--
2.30.2



2023-07-17 01:36:33

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH v4] wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()



> -----Original Message-----
> From: Zhang Shurong <[email protected]>
> Sent: Saturday, July 15, 2023 9:43 PM
> To: Ping-Ke Shih <[email protected]>; [email protected]; [email protected]
> Cc: [email protected]; [email protected]; [email protected]; Zhang Shurong
> <[email protected]>
> Subject: [PATCH v4] wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()
>
> If there is a failure during kstrtobool_from_user()
> rtw89_debug_priv_btc_manual_set should return a negative error code
> instead of returning the count directly.
>
> Fix this bug by returning an error code instead of a count after
> a failed call of the function "kstrtobool_from_user". Moreover
> I omitted the label "out" with this source code correction.
>
> Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
> Signed-off-by: Zhang Shurong <[email protected]>

Acked-by: Ping-Ke Shih <[email protected]>

> ---
> Changes in v2:
> - Corrected the format of this patch
> - Used variable ret instead of goto out
> Changes in v3:
> - Improved change description
> Changes in v4:
> - Improved change description
>

Normally, we preserve three '-' as delimiter here. I tried to use pwclient to
apply this patch, and fortunately it works. So, I think no need to resend because
of this.

[...]


2023-07-25 15:02:53

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v4] wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()

Zhang Shurong <[email protected]> wrote:

> If there is a failure during kstrtobool_from_user()
> rtw89_debug_priv_btc_manual_set should return a negative error code
> instead of returning the count directly.
>
> Fix this bug by returning an error code instead of a count after
> a failed call of the function "kstrtobool_from_user". Moreover
> I omitted the label "out" with this source code correction.
>
> Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
> Signed-off-by: Zhang Shurong <[email protected]>
> Acked-by: Ping-Ke Shih <[email protected]>

Patch applied to wireless-next.git, thanks.

59b4cc439f18 wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches