Skip to content

Commit

Permalink
iwlwifi: pcie: don't use vid 0
Browse files Browse the repository at this point in the history
In cases of hardware or DMA error, the vid read from
a zeroed location will be 0, and we will access the rxb
at index 0 in the global table, while it may be NULL or
owned by hardware.
Invalidate vid 0 in order to detect the situation and
bail out.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
  • Loading branch information
Sara Sharon authored and Luca Coelho committed Jul 6, 2016
1 parent 3edbc7d commit e25d65f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/net/wireless/intel/iwlwifi/pcie/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ int iwl_pcie_rx_init(struct iwl_trans *trans)
else
list_add(&rxb->list, &def_rxq->rx_used);
trans_pcie->global_table[i] = rxb;
rxb->vid = (u16)i;
rxb->vid = (u16)(i + 1);
}

iwl_pcie_rxq_alloc_rbs(trans, GFP_KERNEL, def_rxq);
Expand Down Expand Up @@ -1249,10 +1249,13 @@ static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue)
*/
u16 vid = le32_to_cpu(rxq->used_bd[i]) & 0x0FFF;

if (WARN(vid >= ARRAY_SIZE(trans_pcie->global_table),
"Invalid rxb index from HW %u\n", (u32)vid))
if (WARN(!vid ||
vid > ARRAY_SIZE(trans_pcie->global_table),
"Invalid rxb index from HW %u\n", (u32)vid)) {
iwl_force_nmi(trans);
goto out;
rxb = trans_pcie->global_table[vid];
}
rxb = trans_pcie->global_table[vid - 1];
} else {
rxb = rxq->queue[i];
rxq->queue[i] = NULL;
Expand Down

0 comments on commit e25d65f

Please sign in to comment.