mwifiex_usb_dnld_fw() submits the RX data URBs as soon as the firmware image has been downloaded, which happens before _mwifiex_fw_dpc() creates the default station interface. A data packet sent by the device in that window is queued to adapter->rx_data_q and handled by mwifiex_rx_work_queue() while the remaining initialization is still in progress. mwifiex_get_priv_by_id() skips the private structures whose bss_mode is still NL80211_IFTYPE_UNSPECIFIED, so mwifiex_handle_rx_packet() falls back to mwifiex_get_priv(MWIFIEX_BSS_ROLE_ANY), which returns the first private structure of the adapter. Its bss_role is zero, that is MWIFIEX_BSS_ROLE_STA, but hist_data is only allocated later by mwifiex_init_priv_params() when the interface is created, so mwifiex_hist_data_add() dereferences a NULL pointer: KASAN: null-ptr-deref in mwifiex_hist_data_add Read of size 4 at addr 0000000000000d28 ... mwifiex_process_rx_packet mwifiex_process_sta_rx_packet mwifiex_handle_rx_packet mwifiex_rx_work_queue priv->netdev is NULL at that point as well, so the packet would also make mwifiex_recv_packet() pass a NULL net_device to eth_type_trans(). Such a private structure cannot receive data yet, so drop the packet instead of entering the receive path. Co-developed-by: Bin Yu Signed-off-by: Bin Yu Co-developed-by: Cheng Wen Signed-off-by: Cheng Wen Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- drivers/net/wireless/marvell/mwifiex/txrx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/txrx.c b/drivers/net/wireless/marvell/mwifiex/txrx.c index f44e22f24511..6c651bfa3bff 100644 --- a/drivers/net/wireless/marvell/mwifiex/txrx.c +++ b/drivers/net/wireless/marvell/mwifiex/txrx.c @@ -43,6 +43,13 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter, return -1; } + if (!priv->netdev) { + mwifiex_dbg(adapter, ERROR, + "data: interface is not ready. Drop RX packet\n"); + dev_kfree_skb_any(skb); + return -1; + } + mwifiex_dbg_dump(adapter, DAT_D, "rx pkt:", skb->data, min_t(size_t, skb->len, DEBUG_DUMP_DATA_MAX_LEN)); -- 2.34.1