Skip to content

Commit 1d8820d

Browse files
Po-Hao HuangKalle Valo
authored andcommitted
rtw88: fix c2h memory leak
Fix erroneous code that leads to unreferenced objects. During H2C operations, some functions returned without freeing the memory that only the function have access to. Release these objects when they're no longer needed to avoid potentially memory leaks. Signed-off-by: Po-Hao Huang <[email protected]> Signed-off-by: Ping-Ke Shih <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1a3ac5c commit 1d8820d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

drivers/net/wireless/realtek/rtw88/coex.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,10 @@ void rtw_coex_info_response(struct rtw_dev *rtwdev, struct sk_buff *skb)
591591
struct rtw_coex *coex = &rtwdev->coex;
592592
u8 *payload = get_payload_from_coex_resp(skb);
593593

594-
if (payload[0] != COEX_RESP_ACK_BY_WL_FW)
594+
if (payload[0] != COEX_RESP_ACK_BY_WL_FW) {
595+
dev_kfree_skb_any(skb);
595596
return;
597+
}
596598

597599
skb_queue_tail(&coex->queue, skb);
598600
wake_up(&coex->wait);
@@ -3515,6 +3517,7 @@ static bool rtw_coex_get_bt_reg(struct rtw_dev *rtwdev,
35153517

35163518
payload = get_payload_from_coex_resp(skb);
35173519
*val = GET_COEX_RESP_BT_REG_VAL(payload);
3520+
dev_kfree_skb_any(skb);
35183521

35193522
return true;
35203523
}
@@ -3533,6 +3536,8 @@ static bool rtw_coex_get_bt_patch_version(struct rtw_dev *rtwdev,
35333536

35343537
payload = get_payload_from_coex_resp(skb);
35353538
*patch_version = GET_COEX_RESP_BT_PATCH_VER(payload);
3539+
dev_kfree_skb_any(skb);
3540+
35363541
return true;
35373542
}
35383543

@@ -3550,6 +3555,8 @@ static bool rtw_coex_get_bt_supported_version(struct rtw_dev *rtwdev,
35503555

35513556
payload = get_payload_from_coex_resp(skb);
35523557
*supported_version = GET_COEX_RESP_BT_SUPP_VER(payload);
3558+
dev_kfree_skb_any(skb);
3559+
35533560
return true;
35543561
}
35553562

@@ -3567,6 +3574,8 @@ static bool rtw_coex_get_bt_supported_feature(struct rtw_dev *rtwdev,
35673574

35683575
payload = get_payload_from_coex_resp(skb);
35693576
*supported_feature = GET_COEX_RESP_BT_SUPP_FEAT(payload);
3577+
dev_kfree_skb_any(skb);
3578+
35703579
return true;
35713580
}
35723581

drivers/net/wireless/realtek/rtw88/fw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,12 @@ void rtw_fw_c2h_cmd_rx_irqsafe(struct rtw_dev *rtwdev, u32 pkt_offset,
245245
break;
246246
case C2H_WLAN_RFON:
247247
complete(&rtwdev->lps_leave_check);
248+
dev_kfree_skb_any(skb);
248249
break;
249250
case C2H_SCAN_RESULT:
250251
complete(&rtwdev->fw_scan_density);
251252
rtw_fw_scan_result(rtwdev, c2h->payload, len);
253+
dev_kfree_skb_any(skb);
252254
break;
253255
default:
254256
/* pass offset for further operation */

drivers/net/wireless/realtek/rtw88/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,7 @@ void rtw_core_deinit(struct rtw_dev *rtwdev)
18991899
destroy_workqueue(rtwdev->tx_wq);
19001900
spin_lock_irqsave(&rtwdev->tx_report.q_lock, flags);
19011901
skb_queue_purge(&rtwdev->tx_report.queue);
1902+
skb_queue_purge(&rtwdev->coex.queue);
19021903
spin_unlock_irqrestore(&rtwdev->tx_report.q_lock, flags);
19031904

19041905
list_for_each_entry_safe(rsvd_pkt, tmp, &rtwdev->rsvd_page_list,

0 commit comments

Comments
 (0)