diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2016-01-02 02:12:38 +0300 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2016-01-07 11:18:50 +0200 |
commit | f7b7caa488eb209f1c63cc98104407c62753e406 (patch) | |
tree | 9cc144d30464f1b37619a2f115936b2577334a9c /drivers | |
parent | ee548d4b1036aaba290a4eec68ba11590ad9cc73 (diff) |
ipw2x00: add checks for dma mapping errors
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/intel/ipw2x00/ipw2100.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c index 36818c7f30b9..f93a7f71c047 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c @@ -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; } @@ -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, |