Skip to content

Commit

Permalink
ipw2x00: add checks for dma mapping errors
Browse files Browse the repository at this point in the history
ipw2100_alloc_skb() and ipw2100_tx_send_data() do not check if mapping
dma memory succeed. The patch adds the checks and failure handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Alexey Khoroshilov authored and Kalle Valo committed Jan 7, 2016
1 parent ee548d4 commit f7b7caa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/net/wireless/intel/ipw2x00/ipw2100.c
Original file line number Diff line number Diff line change
Expand Up @@ -2311,8 +2311,10 @@ static int ipw2100_alloc_skb(struct ipw2100_priv *priv,
packet->dma_addr = pci_map_single(priv->pci_dev, packet->skb->data,
sizeof(struct ipw2100_rx),
PCI_DMA_FROMDEVICE);
/* NOTE: pci_map_single does not return an error code, and 0 is a valid
* dma_addr */
if (pci_dma_mapping_error(priv->pci_dev, packet->dma_addr)) {
dev_kfree_skb(packet->skb);
return -ENOMEM;
}

return 0;
}
Expand Down Expand Up @@ -3183,6 +3185,11 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
LIBIPW_3ADDR_LEN,
tbd->buf_length,
PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(priv->pci_dev,
tbd->host_addr)) {
IPW_DEBUG_TX("dma mapping error\n");
break;
}

IPW_DEBUG_TX("data frag tbd TX%d P=%08x L=%d\n",
txq->next, tbd->host_addr,
Expand Down

0 comments on commit f7b7caa

Please sign in to comment.