mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set()
@ 2023-07-04 16:55 Zhang Shurong
  2023-07-04 17:22 ` Larry Finger
  2023-07-05  0:16 ` Ping-Ke Shih
  0 siblings, 2 replies; 3+ messages in thread
From: Zhang Shurong @ 2023-07-04 16:55 UTC (permalink / raw)
  To: pkshih; +Cc: kvalo, linux-wireless, linux-kernel, Zhang Shurong

If there is a failure during rtw89_fw_h2c_raw() rtw89_debug_priv_send_h2c
should return negative error code instead of a positive value count.

Fix this bug by returning correct error code.

The changes in this version:
- fix some compile error

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>

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

diff --git a/drivers/net/wireless/realtek/rtw89/debug.c b/drivers/net/wireless/realtek/rtw89/debug.c
index 1db2d59d33ff..a679f79b85ec 100644
--- a/drivers/net/wireless/realtek/rtw89/debug.c
+++ b/drivers/net/wireless/realtek/rtw89/debug.c
@@ -3026,17 +3026,18 @@ static ssize_t rtw89_debug_priv_send_h2c_set(struct file *filp,
 	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	u8 *h2c;
+	int err = 0;
 	u16 h2c_len = count / 2;
 
 	h2c = rtw89_hex2bin_user(rtwdev, user_buf, count);
 	if (IS_ERR(h2c))
 		return -EFAULT;
 
-	rtw89_fw_h2c_raw(rtwdev, h2c, h2c_len);
+	err = rtw89_fw_h2c_raw(rtwdev, h2c, h2c_len);
 
 	kfree(h2c);
 
-	return count;
+	return err ? err : count;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set()
  2023-07-04 16:55 [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set() Zhang Shurong
@ 2023-07-04 17:22 ` Larry Finger
  2023-07-05  0:16 ` Ping-Ke Shih
  1 sibling, 0 replies; 3+ messages in thread
From: Larry Finger @ 2023-07-04 17:22 UTC (permalink / raw)
  To: Zhang Shurong, pkshih; +Cc: kvalo, linux-wireless, linux-kernel

On 7/4/23 11:55, Zhang Shurong wrote:
> If there is a failure during rtw89_fw_h2c_raw() rtw89_debug_priv_send_h2c
> should return negative error code instead of a positive value count.
> 
> Fix this bug by returning correct error code.
> 
> The changes in this version:
> - fix some compile error
> 
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>

I have two comments on the patch itself:

1) Whenever you have a fix for the code, you need to annotate it using the 
"Fixes: tag". See file Documentation/process/submitting-patches.rst in your 
source tree.

2) The version change stuff should be in the following order:

Signed-off-by: ....
---
v2 - fixed compile error
---
Body of patch.

Placing it where you did would cause the details of "making the sausage" be 
saved in the commit log. The reviewer and maintainer need to see it, but not the 
end user.

Larry


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set()
  2023-07-04 16:55 [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set() Zhang Shurong
  2023-07-04 17:22 ` Larry Finger
@ 2023-07-05  0:16 ` Ping-Ke Shih
  1 sibling, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2023-07-05  0:16 UTC (permalink / raw)
  To: Zhang Shurong; +Cc: kvalo, linux-wireless, linux-kernel



> -----Original Message-----
> From: Zhang Shurong <zhang_shurong@foxmail.com>
> Sent: Wednesday, July 5, 2023 12:55 AM
> To: Ping-Ke Shih <pkshih@realtek.com>
> Cc: kvalo@kernel.org; linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; Zhang Shurong
> <zhang_shurong@foxmail.com>
> Subject: [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set()
> 
> If there is a failure during rtw89_fw_h2c_raw() rtw89_debug_priv_send_h2c
> should return negative error code instead of a positive value count.
> 
> Fix this bug by returning correct error code.
> 
> The changes in this version:
> - fix some compile error

As Larry mentioned, this should be added after delimiter '---'.

> 
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> 
> update

Also, remove this 'update'.

> ---
>  drivers/net/wireless/realtek/rtw89/debug.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/debug.c b/drivers/net/wireless/realtek/rtw89/debug.c
> index 1db2d59d33ff..a679f79b85ec 100644
> --- a/drivers/net/wireless/realtek/rtw89/debug.c
> +++ b/drivers/net/wireless/realtek/rtw89/debug.c
> @@ -3026,17 +3026,18 @@ static ssize_t rtw89_debug_priv_send_h2c_set(struct file *filp,
>         struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
>         struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;

Move 'int err = 0' here in reverse X'mas tree order, and use 'int ret = 0' instead,
so people don't need to guess if there is special meaning of 'err', which is just
a regular error code. 

>         u8 *h2c;
> +       int err = 0;
>         u16 h2c_len = count / 2;
> 
>         h2c = rtw89_hex2bin_user(rtwdev, user_buf, count);
>         if (IS_ERR(h2c))
>                 return -EFAULT;
> 
> -       rtw89_fw_h2c_raw(rtwdev, h2c, h2c_len);
> +       err = rtw89_fw_h2c_raw(rtwdev, h2c, h2c_len);
> 
>         kfree(h2c);
> 
> -       return count;
> +       return err ? err : count;
>  }
> 
>  static int
> --
> 2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-05  0:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 16:55 [PATCH v2] wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set() Zhang Shurong
2023-07-04 17:22 ` Larry Finger
2023-07-05  0:16 ` Ping-Ke Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®