[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260122041450.2325560-3-s9430939@naver.com>
Date: Thu, 22 Jan 2026 13:14:49 +0900
From: Minu Jin <s9430939@...er.com>
To: gregkh@...uxfoundation.org
Cc: andriy.shevchenko@...ux.intel.com,
abrahamadekunle50@...il.com,
zxcv2569763104@...il.com,
milospuric856@...il.com,
karanja99erick@...il.com,
weibu@...admin.org,
dan.carpenter@...aro.org,
linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Minu Jin <s9430939@...er.com>
Subject: [PATCH v5 2/3] staging: rtl8723bs: update callers to handle negative error codes
Currently, several callers of _rtw_pktfile_read() ignore its return
value. As _rtw_pktfile_read() is updated to return negative error codes
on failure, these return values must be checked to prevent silent failures.
To address this,
this patch implements a proper error propagation mechanism:
1. Add missing error checks: Insert 'if (ret < 0)' checks immediately
after _rtw_pktfile_read() calls in set_qos(), update_attrib(), and
rtw_xmitframe_coalesce(). This ensures that any negative error
code is caught and returned.
2. Enable error propagation: Update set_qos() return type from void to
int to pass these error codes up the stack instead of swallowing them.
3. Update upper-layer handling: Modify callers like rtw_xmit() and
xmit_xmitframes() to check for '!= _SUCCESS' instead of '== _FAIL'.
This allows them to catch both generic failures (0) and the newly
propagated negative error codes from their respective callees
(update_attrib and rtw_xmitframe_coalesce).
Specific changes include:
- set_qos():
Change return type to int and add check for negative returns.
- update_attrib(), rtw_xmitframe_coalesce():
Add check for negative returns.
- rtw_xmit(), xmit_xmitframes(): Update
error check logic to '!= _SUCCESS'.
Signed-off-by: Minu Jin <s9430939@...er.com>
---
drivers/staging/rtl8723bs/core/rtw_xmit.c | 44 ++++++++++++++-----
.../staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +--
2 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 21690857fd62..13eb0e3eae62 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -596,23 +596,31 @@ u8 qos_acm(u8 acm_mask, u8 priority)
return priority;
}
-static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
+static int set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
{
struct ethhdr etherhdr;
struct iphdr ip_hdr;
s32 UserPriority = 0;
+ int ret;
_rtw_open_pktfile(ppktfile->pkt, ppktfile);
- _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN);
+ ret = _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN);
+ if (ret < 0)
+ return ret;
/* get UserPriority from IP hdr */
if (pattrib->ether_type == 0x0800) {
- _rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr));
+ ret = _rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr));
+ if (ret < 0)
+ return ret;
+
UserPriority = ip_hdr.tos >> 5;
}
pattrib->priority = UserPriority;
pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN;
pattrib->subtype = WIFI_QOS_DATA_TYPE;
+
+ return 0;
}
static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib)
@@ -626,9 +634,12 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
signed int res = _SUCCESS;
+ int ret;
_rtw_open_pktfile(pkt, &pktfile);
- _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN);
+ ret = _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN);
+ if (ret < 0)
+ return ret;
pattrib->ether_type = ntohs(etherhdr.h_proto);
@@ -655,7 +666,9 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
u8 tmp[24];
- _rtw_pktfile_read(&pktfile, &tmp[0], 24);
+ ret = _rtw_pktfile_read(&pktfile, &tmp[0], 24);
+ if (ret < 0)
+ return ret;
pattrib->dhcp_pkt = 0;
if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */
@@ -737,11 +750,16 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
pattrib->priority = 0;
if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) {
- if (pattrib->qos_en)
- set_qos(&pktfile, pattrib);
+ if (pattrib->qos_en) {
+ ret = set_qos(&pktfile, pattrib);
+ if (ret < 0)
+ return ret;
+ }
} else {
if (pqospriv->qos_option) {
- set_qos(&pktfile, pattrib);
+ ret = set_qos(&pktfile, pattrib);
+ if (ret < 0)
+ return ret;
if (pmlmepriv->acm_mask != 0)
pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority);
@@ -1039,6 +1057,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
s32 bmcst = is_multicast_ether_addr(pattrib->ra);
s32 res = _SUCCESS;
+ int ret;
if (!pxmitframe->buf_addr)
return _FAIL;
@@ -1054,7 +1073,9 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
}
_rtw_open_pktfile(pkt, &pktfile);
- _rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen);
+ ret = _rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen);
+ if (ret < 0)
+ return ret;
frg_inx = 0;
frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */
@@ -1096,6 +1117,9 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
mem_sz = _rtw_pktfile_read(&pktfile, pframe, mpdu_len);
}
+ if (mem_sz < 0)
+ return mem_sz;
+
pframe += mem_sz;
if ((pattrib->icv_len > 0) && (pattrib->bswenc)) {
@@ -1958,7 +1982,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
res = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
- if (res == _FAIL) {
+ if (res != _SUCCESS) {
rtw_free_xmitframe(pxmitpriv, pxmitframe);
return -1;
}
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index abb6fdfe7e1f..55df66ec5f4c 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -289,10 +289,10 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
pxmitframe->buf_addr = pxmitbuf->ptail;
ret = rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe);
- if (ret == _FAIL) {
+ if (ret != _SUCCESS) {
netdev_err(padapter->pnetdev,
- "%s: coalesce FAIL!",
- __func__);
+ "%s: coalesce failed with error %d\n",
+ __func__, ret);
/* Todo: error handler */
} else {
k++;
--
2.43.0
Powered by blists - more mailing lists