* [PATCH] ipw2x00: add checks for dma mapping errors
@ 2016-01-01 23:12 Alexey Khoroshilov
2016-01-07 9:19 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2016-01-01 23:12 UTC (permalink / raw)
To: Stanislav Yakovlev, Kalle Valo
Cc: Alexey Khoroshilov, linux-wireless, netdev, linux-kernel, ldv-project
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>
---
drivers/net/wireless/ipw2x00/ipw2100.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index 36818c7f30b9..f93a7f71c047 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/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,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: ipw2x00: add checks for dma mapping errors
2016-01-01 23:12 [PATCH] ipw2x00: add checks for dma mapping errors Alexey Khoroshilov
@ 2016-01-07 9:19 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2016-01-07 9:19 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Stanislav Yakovlev, Alexey Khoroshilov, linux-wireless, netdev,
linux-kernel, ldv-project
> 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>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-07 9:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01 23:12 [PATCH] ipw2x00: add checks for dma mapping errors Alexey Khoroshilov
2016-01-07 9:19 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).