drivers/net/wireless/nxp/nxpwifi/uap_txrx.c:249 nxpwifi_handle_uap_rx_forward() warn: inconsistent indenting
Subsystems (2)
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 415606a7be939835db9b0d6b711887586646346d commit: 73b01e57ed3e3d6102c0cbcb21f62086c5429437 [4988/11507] wifi: nxp: add nxpwifi driver for IW61x config: openrisc-randconfig-r071-20260802 (https://download.01.org/0day-ci/archive/20260802/[email protected]/config) compiler: or1k-linux-gcc (GCC) 16.1.0 smatch: v0.5.0-9187-g5189e3fb
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/net/wireless/nxp/nxpwifi/uap_txrx.c:249 nxpwifi_handle_uap_rx_forward() warn: inconsistent indenting drivers/net/wireless/nxp/nxpwifi/11n.c:454 nxpwifi_11n_delete_tx_ba_stream_tbl_entry() error: we previously assumed 'tbl' could be null (see line 454) drivers/net/wireless/nxp/nxpwifi/11n.c:705 nxpwifi_del_tx_ba_stream_tbl_by_ra() error: dereferencing freed memory 'tbl' (line 707) drivers/net/wireless/nxp/nxpwifi/main.h:1185 nxpwifi_get_unused_bss_num() warn: signedness bug returning '(-2)' drivers/net/wireless/nxp/nxpwifi/util.c:802 nxpwifi_recv_packet_to_monif() warn: always true condition '(ext.timestamp.position <= 15) => (0-15 <= 15)' drivers/net/wireless/nxp/nxpwifi/sdio.c:1350 nxpwifi_process_int_status() warn: missing unwind goto? drivers/net/wireless/nxp/nxpwifi/main.c:207 nxpwifi_drain_tx() warn: inconsistent indenting drivers/net/wireless/nxp/nxpwifi/11ax.c:422 nxpwifi_is_11ax_twt_supported() error: we previously assumed 'bss_desc' could be null (see line 416)
vim +249 drivers/net/wireless/nxp/nxpwifi/uap_txrx.c
217
218 /* AP fwd: mcast/bcast -> up + bridge; unicast -> bridge if RA assoc, else up. */
219 int nxpwifi_handle_uap_rx_forward(struct nxpwifi_private *priv,
220 struct sk_buff *skb)
221 {
222 struct nxpwifi_adapter *adapter = priv->adapter;
223 struct uap_rxpd *uap_rx_pd;
224 struct rx_packet_hdr *rx_pkt_hdr;
225 u8 ra[ETH_ALEN];
226 struct sk_buff *skb_uap;
227 struct nxpwifi_sta_node *node;
228
229 uap_rx_pd = (struct uap_rxpd *)(skb->data);
230 rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
231
232 /* don't do packet forwarding in disconnected state */
233 if (!priv->media_connected) {
234 nxpwifi_dbg(adapter, ERROR,
235 "drop packet in disconnected state.\n");
236 dev_kfree_skb_any(skb);
237 return 0;
238 }
239
240 memcpy(ra, rx_pkt_hdr->eth803_hdr.h_dest, ETH_ALEN);
241
242 if (is_multicast_ether_addr(ra)) {
243 skb_uap = skb_copy(skb, GFP_ATOMIC);
244 if (likely(skb_uap)) {
245 nxpwifi_uap_queue_bridged_pkt(priv, skb_uap);
246 } else {
247 nxpwifi_dbg(adapter, ERROR,
248 "failed to copy skb for uAP\n"); > 249 priv->stats.rx_dropped++; 250 dev_kfree_skb_any(skb);
251 return -ENOMEM;
252 }
253 } else {
254 node = nxpwifi_get_sta_entry_rcu(priv, ra);
255 if (node) {
256 /* Requeue Intra-BSS packet */
257 nxpwifi_uap_queue_bridged_pkt(priv, skb);
258 return 0;
259 }
260 }
261
262 /* Forward unicat/Inter-BSS packets to kernel. */
263 return nxpwifi_process_rx_packet(priv, skb);
264 }
265
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH 1/1 wifi: nxpwifi: fix multiple static analysis errors and warnings
Fix various development-phase bugs, code quality, and logical issues reported by the kernel test robot (using the Smatch static analysis tool).
The following addressable fixes are included:
- 11n.c & 11ax.c: Fix potential NULL pointer dereferences by correcting logical operators (&& to ||) in 11n.c and hoisting the bss_desc verification to the top of the function in 11ax.c.
- 11n.c: Fix a severe Use-After-Free (UAF) memory corruption during RCU list traversal. Restore the proper list_for_each_entry_safe() loop structure along with the required array index [i] within the locked writer path.
- sdio.c: Fix a missing unwind resource cleanup pathway where a protocol error branch returned directly via -EINVAL instead of using 'goto term_cmd', leaving the SDIO hardware state machine out of sync.
- main.h: Fix a signedness mismatch bug where nxpwifi_get_unused_bss_num() could return -2 as an unsigned integer fallback.
- util.c: Remove a redundant and dead condition check (position <= 15) which was always true for a 4-bit unsigned bit-field member variable.
- cfg80211.c: Clean up a dead unreachable 'return 0' at the bottom of the switch-case logic.
- uap_txrx.c: Clean up mismatched and inconsistent indentations within the handling of multicast RX forward paths.
--- drivers/net/wireless/nxp/nxpwifi/11ax.c | 5 ++- drivers/net/wireless/nxp/nxpwifi/11n.c | 6 +-- drivers/net/wireless/nxp/nxpwifi/cfg80211.c | 13 ++++-- drivers/net/wireless/nxp/nxpwifi/main.c | 2 +- drivers/net/wireless/nxp/nxpwifi/main.h | 21 ++++++---- drivers/net/wireless/nxp/nxpwifi/sdio.c | 3 +- drivers/net/wireless/nxp/nxpwifi/uap_txrx.c | 4 +- drivers/net/wireless/nxp/nxpwifi/util.c | 46 ++++++++++----------- 8 files changed, 57 insertions(+), 43 deletions(-)
drivers/net/wireless/nxp/nxpwifi/11ax.c +4 -1
@@ -413,7 +413,10 @@ bool nxpwifi_is_11ax_twt_supported(struct nxpwifi_private *priv,struct nxpwifi_ie_types_he_cap *user_he_cap;struct nxpwifi_ie_types_he_cap *hw_he_cap; -if (bss_desc && (!nxpwifi_is_ap_11ax_twt_supported (bss_desc))) { +if (!bss_desc) +return false; + +if (!nxpwifi_is_ap_11ax_twt_supported (bss_desc)) {nxpwifi_dbg (priv->adapter,MSG ,"AP don't support twt feature\n" );return false;
drivers/net/wireless/nxp/nxpwifi/11n.c +3 -3
@@ -451,7 +451,7 @@ void nxpwifi_11n_delete_tx_ba_stream_tbl_entry(struct nxpwifi_private *priv, struct nxpwifi_tx_ba_stream_tbl *tbl) { -if (!tbl &&nxpwifi_is_tx_ba_stream_ptr_valid (priv, tbl)) +if (!tbl ||nxpwifi_is_tx_ba_stream_ptr_valid (priv, tbl))return ; nxpwifi_dbg(priv->adapter, INFO,
@@ -694,7 +694,7 @@ int nxpwifi_get_tx_ba_stream_tbl(struct nxpwifi_private *priv,/* Delete Tx BA stream entry by RA. */ void nxpwifi_del_tx_ba_stream_tbl_by_ra (struct nxpwifi_private *priv,u8 *ra) { -struct nxpwifi_tx_ba_stream_tbl *tbl; +struct nxpwifi_tx_ba_stream_tbl *tbl, *tmp;int i;if (!ra)
@@ -702,7 +702,7 @@ void nxpwifi_del_tx_ba_stream_tbl_by_ra(struct nxpwifi_private *priv, u8 *ra)for (i =0 ; i <MAX_NUM_TID ; i++) {spin_lock_bh (&priv->tx_ba_stream_tbl_lock[i]); -list_for_each_entry_rcu (tbl, &priv->tx_ba_stream_tbl_ptr[i], list) +list_for_each_entry_safe (tbl, tmp, &priv->tx_ba_stream_tbl_ptr[i], list)if (!memcmp (tbl->ra, ra,ETH_ALEN ))nxpwifi_11n_delete_tx_ba_stream_tbl_entry (priv, tbl);
drivers/net/wireless/nxp/nxpwifi/cfg80211.c +9 -4
@@ -717,6 +717,7 @@ nxpwifi_init_new_priv_params(struct nxpwifi_private *priv, enum nl80211_iftype type) {struct nxpwifi_adapter *adapter = priv->adapter; +int ret;nxpwifi_init_priv (priv);
@@ -740,7 +741,14 @@ nxpwifi_init_new_priv_params(struct nxpwifi_private *priv,return -EOPNOTSUPP ; } - priv->bss_num =nxpwifi_get_unused_bss_num (adapter, priv->bss_type); + ret =nxpwifi_get_unused_bss_num (adapter, priv->bss_type, &priv->bss_num); + +if (ret) { +nxpwifi_dbg (adapter,ERROR , +"%s: no unused bss_num for type %d\n" , + dev->name, priv->bss_type); +return ret; + }flush_workqueue (adapter->workqueue);atomic_set (&adapter->iface_changing,0 );
@@ -943,7 +951,6 @@ nxpwifi_cfg80211_change_virtual_intf(struct wiphy *wiphy,case NL80211_IFTYPE_STATION :return nxpwifi_change_vif_to_sta (dev, curr_iftype, type, params); -break ;default : goto errnotsupp; }
@@ -952,8 +959,6 @@ nxpwifi_cfg80211_change_virtual_intf(struct wiphy *wiphy, goto errnotsupp; } -return 0 ; - errnotsupp: nxpwifi_dbg(priv->adapter, ERROR, "unsupported interface type transition: %d to %d\n",
drivers/net/wireless/nxp/nxpwifi/main.c +1 -1
@@ -204,7 +204,7 @@ static bool nxpwifi_drain_tx(struct nxpwifi_adapter *adapter) NXPWIFI_ASYNC_CMD); adapter->hs_activated_manually = false; } -nxpwifi_process_bypass_tx (adapter); +nxpwifi_process_bypass_tx (adapter);if (adapter->hs_activated) {clear_bit (NXPWIFI_IS_HS_CONFIGURED , &adapter->work_flags);
drivers/net/wireless/nxp/nxpwifi/main.h +14 -7
@@ -1166,8 +1166,9 @@ nxpwifi_get_priv(struct nxpwifi_adapter *adapter, }/* find unused BSS number for new interface */ -static inline u8 -nxpwifi_get_unused_bss_num (struct nxpwifi_adapter *adapter,u8 bss_type) +static inline int +nxpwifi_get_unused_bss_num (struct nxpwifi_adapter *adapter,u8 bss_type, +u8 *bss_num) {u8 i, j;int index[NXPWIFI_MAX_BSS_NUM ];
@@ -1179,9 +1180,14 @@ nxpwifi_get_unused_bss_num(struct nxpwifi_adapter *adapter, u8 bss_type) NL80211_IFTYPE_UNSPECIFIED)) { index[adapter->priv[i]->bss_num] =1 ; } -for (j =0 ; j <NXPWIFI_MAX_BSS_NUM ; j++) -if (!index[j]) -return j; + +for (j =0 ; j <NXPWIFI_MAX_BSS_NUM ; j++) { +if (!index[j]) { + *bss_num = j; +return 0 ; + } + } +return -ENOENT ; }
@@ -1195,8 +1201,9 @@ nxpwifi_get_unused_priv_by_bss_type(struct nxpwifi_adapter *adapter,for (i =0 ; i < adapter->priv_num; i++)if (adapter->priv[i]->bss_mode ==NL80211_IFTYPE_UNSPECIFIED ) { - adapter->priv[i]->bss_num = -nxpwifi_get_unused_bss_num (adapter, bss_type); +if (nxpwifi_get_unused_bss_num (adapter, bss_type, + &adapter->priv[i]->bss_num)) +return NULL ;break ; }
drivers/net/wireless/nxp/nxpwifi/sdio.c +2 -1
@@ -1347,7 +1347,8 @@ static int nxpwifi_process_int_status(struct nxpwifi_adapter *adapter, u8 sdio_i ((rx_blocks * NXPWIFI_SDIO_BLOCK_SIZE) > card->mpa_rx.buf_size))) {nxpwifi_dbg (adapter,ERROR ,"invalid rx_len=%d\n" , rx_len); -return -EINVAL ; + ret = -EINVAL ; + goto term_cmd; } rx_len = (u16)(rx_blocks *NXPWIFI_SDIO_BLOCK_SIZE );
drivers/net/wireless/nxp/nxpwifi/uap_txrx.c +2 -2
@@ -246,8 +246,8 @@ int nxpwifi_handle_uap_rx_forward(struct nxpwifi_private *priv, }else {nxpwifi_dbg (adapter,ERROR ,"failed to copy skb for uAP\n" ); - priv->stats.rx_dropped++; -dev_kfree_skb_any (skb); + priv->stats.rx_dropped++; +dev_kfree_skb_any (skb);return -ENOMEM ; } }else {
drivers/net/wireless/nxp/nxpwifi/util.c +22 -24
56 lines not on this page · raw message
base-commit: 6c5fc504d0d6934132637aa3db4b9b58148eaa78
Signature · 1 line
2.34.1
PATCH v2 1/1 wifi: nxpwifi: fix multiple static analysis errors and warnings
In reply to kernel test robotFrom: Jeff Chen <[email protected]>
Fix various development-phase bugs, code quality, and logical issues reported by the kernel test robot (using the Smatch static analysis tool).
The following addressable fixes are included:
- 11n.c & 11ax.c: Fix potential NULL pointer dereferences by correcting logical operators (&& to ||) in 11n.c and hoisting the bss_desc verification to the top of the function in 11ax.c.
- 11n.c: Fix a severe Use-After-Free (UAF) memory corruption during RCU list traversal. Restore the proper list_for_each_entry_safe() loop structure along with the required array index [i] within the locked writer path.
- sdio.c: Fix a missing unwind resource cleanup pathway where a protocol error branch returned directly via -EINVAL instead of using 'goto term_cmd', leaving the SDIO hardware state machine out of sync.
- main.h: Fix a signedness mismatch bug where nxpwifi_get_unused_bss_num() could return -2 as an unsigned integer fallback.
- util.c: Remove a redundant and dead condition check (position <= 15) which was always true for a 4-bit unsigned bit-field member variable.
- cfg80211.c: Clean up a dead unreachable 'return 0' at the bottom of the switch-case logic.
- uap_txrx.c: Clean up mismatched and inconsistent indentations within the handling of multicast RX forward paths.
--- drivers/net/wireless/nxp/nxpwifi/11ax.c | 5 ++- drivers/net/wireless/nxp/nxpwifi/11n.c | 7 +-- drivers/net/wireless/nxp/nxpwifi/cfg80211.c | 14 ++++-- drivers/net/wireless/nxp/nxpwifi/main.c | 2 +- drivers/net/wireless/nxp/nxpwifi/main.h | 21 ++++++--- drivers/net/wireless/nxp/nxpwifi/sdio.c | 3 +- drivers/net/wireless/nxp/nxpwifi/uap_txrx.c | 4 +- drivers/net/wireless/nxp/nxpwifi/util.c | 47 ++++++++++----------- 8 files changed, 60 insertions(+), 43 deletions(-)
drivers/net/wireless/nxp/nxpwifi/11ax.c +4 -1
@@ -413,7 +413,10 @@ bool nxpwifi_is_11ax_twt_supported(struct nxpwifi_private *priv,struct nxpwifi_ie_types_he_cap *user_he_cap;struct nxpwifi_ie_types_he_cap *hw_he_cap; -if (bss_desc && (!nxpwifi_is_ap_11ax_twt_supported (bss_desc))) { +if (!bss_desc) +return false; + +if (!nxpwifi_is_ap_11ax_twt_supported (bss_desc)) {nxpwifi_dbg (priv->adapter,MSG ,"AP don't support twt feature\n" );return false;
drivers/net/wireless/nxp/nxpwifi/11n.c +4 -3
@@ -451,7 +451,7 @@ void nxpwifi_11n_delete_tx_ba_stream_tbl_entry(struct nxpwifi_private *priv, struct nxpwifi_tx_ba_stream_tbl *tbl) { -if (!tbl &&nxpwifi_is_tx_ba_stream_ptr_valid (priv, tbl)) +if (!tbl ||nxpwifi_is_tx_ba_stream_ptr_valid (priv, tbl))return ; nxpwifi_dbg(priv->adapter, INFO,
@@ -694,7 +694,7 @@ int nxpwifi_get_tx_ba_stream_tbl(struct nxpwifi_private *priv,/* Delete Tx BA stream entry by RA. */ void nxpwifi_del_tx_ba_stream_tbl_by_ra (struct nxpwifi_private *priv,u8 *ra) { -struct nxpwifi_tx_ba_stream_tbl *tbl; +struct nxpwifi_tx_ba_stream_tbl *tbl, *tmp;int i;if (!ra)
@@ -702,7 +702,8 @@ void nxpwifi_del_tx_ba_stream_tbl_by_ra(struct nxpwifi_private *priv, u8 *ra)for (i =0 ; i <MAX_NUM_TID ; i++) {spin_lock_bh (&priv->tx_ba_stream_tbl_lock[i]); -list_for_each_entry_rcu (tbl, &priv->tx_ba_stream_tbl_ptr[i], list) +list_for_each_entry_safe (tbl, tmp, + &priv->tx_ba_stream_tbl_ptr[i], list)if (!memcmp (tbl->ra, ra,ETH_ALEN ))nxpwifi_11n_delete_tx_ba_stream_tbl_entry (priv, tbl);
drivers/net/wireless/nxp/nxpwifi/cfg80211.c +10 -4
@@ -717,6 +717,7 @@ nxpwifi_init_new_priv_params(struct nxpwifi_private *priv, enum nl80211_iftype type) {struct nxpwifi_adapter *adapter = priv->adapter; +int ret;nxpwifi_init_priv (priv);
@@ -740,7 +741,15 @@ nxpwifi_init_new_priv_params(struct nxpwifi_private *priv,return -EOPNOTSUPP ; } - priv->bss_num =nxpwifi_get_unused_bss_num (adapter, priv->bss_type); + ret =nxpwifi_get_unused_bss_num (adapter, priv->bss_type, + &priv->bss_num); + +if (ret) { +nxpwifi_dbg (adapter,ERROR , +"%s: no unused bss_num for type %d\n" , + dev->name, priv->bss_type); +return ret; + }flush_workqueue (adapter->workqueue);atomic_set (&adapter->iface_changing,0 );
@@ -943,7 +952,6 @@ nxpwifi_cfg80211_change_virtual_intf(struct wiphy *wiphy,case NL80211_IFTYPE_STATION :return nxpwifi_change_vif_to_sta (dev, curr_iftype, type, params); -break ;default : goto errnotsupp; }
@@ -952,8 +960,6 @@ nxpwifi_cfg80211_change_virtual_intf(struct wiphy *wiphy, goto errnotsupp; } -return 0 ; - errnotsupp: nxpwifi_dbg(priv->adapter, ERROR, "unsupported interface type transition: %d to %d\n",
drivers/net/wireless/nxp/nxpwifi/main.c +1 -1
@@ -204,7 +204,7 @@ static bool nxpwifi_drain_tx(struct nxpwifi_adapter *adapter) NXPWIFI_ASYNC_CMD); adapter->hs_activated_manually = false; } -nxpwifi_process_bypass_tx (adapter); +nxpwifi_process_bypass_tx (adapter);if (adapter->hs_activated) {clear_bit (NXPWIFI_IS_HS_CONFIGURED , &adapter->work_flags);
drivers/net/wireless/nxp/nxpwifi/main.h +14 -7
@@ -1166,8 +1166,9 @@ nxpwifi_get_priv(struct nxpwifi_adapter *adapter, }/* find unused BSS number for new interface */ -static inline u8 -nxpwifi_get_unused_bss_num (struct nxpwifi_adapter *adapter,u8 bss_type) +static inline int +nxpwifi_get_unused_bss_num (struct nxpwifi_adapter *adapter,u8 bss_type, +u8 *bss_num) {u8 i, j;int index[NXPWIFI_MAX_BSS_NUM ];
@@ -1179,9 +1180,14 @@ nxpwifi_get_unused_bss_num(struct nxpwifi_adapter *adapter, u8 bss_type) NL80211_IFTYPE_UNSPECIFIED)) { index[adapter->priv[i]->bss_num] =1 ; } -for (j =0 ; j <NXPWIFI_MAX_BSS_NUM ; j++) -if (!index[j]) -return j; + +for (j =0 ; j <NXPWIFI_MAX_BSS_NUM ; j++) { +if (!index[j]) { + *bss_num = j; +return 0 ; + } + } +return -ENOENT ; }
@@ -1195,8 +1201,9 @@ nxpwifi_get_unused_priv_by_bss_type(struct nxpwifi_adapter *adapter,for (i =0 ; i < adapter->priv_num; i++)if (adapter->priv[i]->bss_mode ==NL80211_IFTYPE_UNSPECIFIED ) { - adapter->priv[i]->bss_num = -nxpwifi_get_unused_bss_num (adapter, bss_type); +if (nxpwifi_get_unused_bss_num (adapter, bss_type, + &adapter->priv[i]->bss_num)) +return NULL ;break ; }
drivers/net/wireless/nxp/nxpwifi/sdio.c +2 -1
@@ -1347,7 +1347,8 @@ static int nxpwifi_process_int_status(struct nxpwifi_adapter *adapter, u8 sdio_i ((rx_blocks * NXPWIFI_SDIO_BLOCK_SIZE) > card->mpa_rx.buf_size))) {nxpwifi_dbg (adapter,ERROR ,"invalid rx_len=%d\n" , rx_len); -return -EINVAL ; + ret = -EINVAL ; + goto term_cmd; } rx_len = (u16)(rx_blocks *NXPWIFI_SDIO_BLOCK_SIZE );
drivers/net/wireless/nxp/nxpwifi/uap_txrx.c +2 -2
@@ -246,8 +246,8 @@ int nxpwifi_handle_uap_rx_forward(struct nxpwifi_private *priv, }else {nxpwifi_dbg (adapter,ERROR ,"failed to copy skb for uAP\n" ); - priv->stats.rx_dropped++; -dev_kfree_skb_any (skb); + priv->stats.rx_dropped++; +dev_kfree_skb_any (skb);return -ENOMEM ; } }else {
drivers/net/wireless/nxp/nxpwifi/util.c +23 -24
57 lines not on this page · raw message
base-commit: 6c5fc504d0d6934132637aa3db4b9b58148eaa78
Signature · 1 line
2.34.1