Skip to content

Commit 08326a9

Browse files
jmberg-intellucacoelho
authored andcommitted
iwlwifi: pcie: fix indexing in command dump for new HW
We got a crash in iwl_trans_pcie_get_cmdlen(), while the TFD was being accessed to sum up the lengths. We want to access the TFD here, which is the information for the hardware. We always only allocate 32 buffers for the cmd queue, but on newer hardware (using TFH) we can also allocate only a shorter hardware array, also only 32 TFDs. Prior to the TFH, we had to allocate a bigger TFD array but would make those point to a smaller set of buffers. Additionally, now max_tfd_queue_size is up to 65536, so we can access *way* out of bounds of a really only 32-entry array, so it crashes. Fix this by making the TFD index depend on which hardware we are using right now. While changing the calculation, also fix it to not use void ptr arithmetic, but cast to u8 * before. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Luca Coelho <[email protected]>
1 parent a2113cc commit 08326a9

File tree

1 file changed

+8
-2
lines changed
  • drivers/net/wireless/intel/iwlwifi/pcie

1 file changed

+8
-2
lines changed

drivers/net/wireless/intel/iwlwifi/pcie/trans.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3272,11 +3272,17 @@ static struct iwl_trans_dump_data
32723272
ptr = cmdq->write_ptr;
32733273
for (i = 0; i < cmdq->n_window; i++) {
32743274
u8 idx = iwl_pcie_get_cmd_index(cmdq, ptr);
3275+
u8 tfdidx;
32753276
u32 caplen, cmdlen;
32763277

3278+
if (trans->trans_cfg->use_tfh)
3279+
tfdidx = idx;
3280+
else
3281+
tfdidx = ptr;
3282+
32773283
cmdlen = iwl_trans_pcie_get_cmdlen(trans,
3278-
cmdq->tfds +
3279-
tfd_size * ptr);
3284+
(u8 *)cmdq->tfds +
3285+
tfd_size * tfdidx);
32803286
caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen);
32813287

32823288
if (cmdlen) {

0 commit comments

Comments
 (0)