Skip to content

Commit 5737b45

Browse files
Ping-Ke ShihKalle Valo
authored andcommitted
rtw89: update partition size of firmware header on skb->data
The partition size is used to tell hardware the size of piece we are going to send a firmware. The old code updates the size in constant buffer of firmware, and leads system crash. To fix this, update the size on skb->data after we copy the firmware data into skb. Buglink: https://bugzilla.opensuse.org/show_bug.cgi?id=1188303 Fixes: e3ec701 ("rtw89: add Realtek 802.11ax driver") Reported-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Tested-by: Takashi Iwai <tiwai@suse.de> Tested-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20211119054512.10620-2-pkshih@realtek.com
1 parent a571bc2 commit 5737b45

File tree

2 files changed

+5
-3
lines changed
  • drivers/net/wireless/realtek/rtw89

2 files changed

+5
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ static int rtw89_fw_hdr_parser(struct rtw89_dev *rtwdev, const u8 *fw, u32 len,
9191
info->section_num = GET_FW_HDR_SEC_NUM(fw);
9292
info->hdr_len = RTW89_FW_HDR_SIZE +
9393
info->section_num * RTW89_FW_SECTION_HDR_SIZE;
94-
SET_FW_HDR_PART_SIZE(fw, FWDL_SECTION_PER_PKT_LEN);
9594

9695
bin = fw + info->hdr_len;
9796

@@ -275,6 +274,7 @@ static int __rtw89_fw_download_hdr(struct rtw89_dev *rtwdev, const u8 *fw, u32 l
275274
}
276275

277276
skb_put_data(skb, fw, len);
277+
SET_FW_HDR_PART_SIZE(skb->data, FWDL_SECTION_PER_PKT_LEN);
278278
rtw89_h2c_pkt_set_hdr_fwdl(rtwdev, skb, FWCMD_TYPE_H2C,
279279
H2C_CAT_MAC, H2C_CL_MAC_FWDL,
280280
H2C_FUNC_MAC_FWHDR_DL, len);

drivers/net/wireless/realtek/rtw89/fw.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ struct rtw89_h2creg_sch_tx_en {
282282
le32_get_bits(*((__le32 *)(fwhdr) + 6), GENMASK(15, 8))
283283
#define GET_FW_HDR_CMD_VERSERION(fwhdr) \
284284
le32_get_bits(*((__le32 *)(fwhdr) + 7), GENMASK(31, 24))
285-
#define SET_FW_HDR_PART_SIZE(fwhdr, val) \
286-
le32p_replace_bits((__le32 *)(fwhdr) + 7, val, GENMASK(15, 0))
285+
static inline void SET_FW_HDR_PART_SIZE(void *fwhdr, u32 val)
286+
{
287+
le32p_replace_bits((__le32 *)fwhdr + 7, val, GENMASK(15, 0));
288+
}
287289

288290
#define SET_CTRL_INFO_MACID(table, val) \
289291
le32p_replace_bits((__le32 *)(table) + 0, val, GENMASK(6, 0))

0 commit comments

Comments
 (0)