Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexey Khoroshilov and committed by
Kalle Valo
f7b7caa4 ee548d4b

+9 -2
+9 -2
drivers/net/wireless/intel/ipw2x00/ipw2100.c
··· 2311 2311 packet->dma_addr = pci_map_single(priv->pci_dev, packet->skb->data, 2312 2312 sizeof(struct ipw2100_rx), 2313 2313 PCI_DMA_FROMDEVICE); 2314 - /* NOTE: pci_map_single does not return an error code, and 0 is a valid 2315 - * dma_addr */ 2314 + if (pci_dma_mapping_error(priv->pci_dev, packet->dma_addr)) { 2315 + dev_kfree_skb(packet->skb); 2316 + return -ENOMEM; 2317 + } 2316 2318 2317 2319 return 0; 2318 2320 } ··· 3185 3183 LIBIPW_3ADDR_LEN, 3186 3184 tbd->buf_length, 3187 3185 PCI_DMA_TODEVICE); 3186 + if (pci_dma_mapping_error(priv->pci_dev, 3187 + tbd->host_addr)) { 3188 + IPW_DEBUG_TX("dma mapping error\n"); 3189 + break; 3190 + } 3188 3191 3189 3192 IPW_DEBUG_TX("data frag tbd TX%d P=%08x L=%d\n", 3190 3193 txq->next, tbd->host_addr,