[PATCH] wifi: rtw89: fw: propagate real error code in rtw89_fw_h2c_add_general_pkt()

Gongwei Li posted 1 patch 3 weeks, 4 days ago
drivers/net/wireless/realtek/rtw89/fw.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH] wifi: rtw89: fw: propagate real error code in rtw89_fw_h2c_add_general_pkt()
Posted by Gongwei Li 3 weeks, 4 days ago
From: Gongwei Li <ligongwei@kylinos.cn>

The error path of rtw89_fw_h2c_add_general_pkt() returns -ENOMEM
unconditionally, which masks the real reason of a failure. In
particular:

* rtw89_fw_h2c_add_pkt_offload() can fail with -ENOSPC when no more
  packet offload slot is available, or with the error of H2C TX, but
  the callers only see -ENOMEM and get misled when debugging.

* For an unsupported type, the switch default case returns -ENOMEM,
  which is misleading and should be -EINVAL.

Return a real error code instead of -ENOMEM, and use -EINVAL for
unsupported types.

Fixes: 5c12bb66b79d ("wifi: rtw89: refine packet offload flow")
Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>
---
  drivers/net/wireless/realtek/rtw89/fw.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index d6a594b75ab2..ab2d0b0cb1e5 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -3013,11 +3013,14 @@ static int rtw89_fw_h2c_add_general_pkt(struct rtw89_dev *rtwdev,
 		skb = rtw89_arp_response_get(rtwdev, rtwvif_link);
 		break;
 	default:
+		ret = -EINVAL;
 		goto err;
 	}
 
-	if (!skb)
+	if (!skb) {
+		ret = -ENOMEM;
 		goto err;
+	}
 
 	ret = rtw89_fw_h2c_add_pkt_offload(rtwdev, &info->id, skb);
 	kfree_skb(skb);
@@ -3031,7 +3034,7 @@ static int rtw89_fw_h2c_add_general_pkt(struct rtw89_dev *rtwdev,
 
 err:
 	kfree(info);
-	return -ENOMEM;
+	return ret;
 }
 
 void rtw89_fw_release_general_pkt_list_vif(struct rtw89_dev *rtwdev,

-- 

2.25.1
Re: [PATCH] wifi: rtw89: fw: propagate real error code in rtw89_fw_h2c_add_general_pkt()
Posted by Ping-Ke Shih 2 weeks, 4 days ago
Gongwei Li <13875017792@163.com> wrote:

> From: Gongwei Li <ligongwei@kylinos.cn>
> 
> The error path of rtw89_fw_h2c_add_general_pkt() returns -ENOMEM
> unconditionally, which masks the real reason of a failure. In
> particular:
> 
> * rtw89_fw_h2c_add_pkt_offload() can fail with -ENOSPC when no more
>   packet offload slot is available, or with the error of H2C TX, but
>   the callers only see -ENOMEM and get misled when debugging.
> 
> * For an unsupported type, the switch default case returns -ENOMEM,
>   which is misleading and should be -EINVAL.
> 
> Return a real error code instead of -ENOMEM, and use -EINVAL for
> unsupported types.
> 
> Fixes: 5c12bb66b79d ("wifi: rtw89: refine packet offload flow")
> Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

5469ea5a14aa wifi: rtw89: fw: propagate real error code in rtw89_fw_h2c_add_general_pkt()

---
https://github.com/pkshih/rtw.git
RE: [PATCH] wifi: rtw89: fw: propagate real error code in rtw89_fw_h2c_add_general_pkt()
Posted by Ping-Ke Shih 3 weeks, 3 days ago
Gongwei Li <13875017792@163.com> wrote:
> From: Gongwei Li <ligongwei@kylinos.cn>
> 
> The error path of rtw89_fw_h2c_add_general_pkt() returns -ENOMEM
> unconditionally, which masks the real reason of a failure. In
> particular:
> 
> * rtw89_fw_h2c_add_pkt_offload() can fail with -ENOSPC when no more
>   packet offload slot is available, or with the error of H2C TX, but
>   the callers only see -ENOMEM and get misled when debugging.
> 
> * For an unsupported type, the switch default case returns -ENOMEM,
>   which is misleading and should be -EINVAL.
> 
> Return a real error code instead of -ENOMEM, and use -EINVAL for
> unsupported types.
> 
> Fixes: 5c12bb66b79d ("wifi: rtw89: refine packet offload flow")

This patch isn't so serious. I'd not add Fixes.

> Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>

Acked-by: Ping-Ke Shih <pkshih@realtek.com>