prism54: fix checks for dma mapping errors
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Fri, 25 Dec 2015 22:42:41 +0000 (01:42 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 31 Dec 2015 08:23:32 +0000 (10:23 +0200)
prism54 checks for dma mapping errors by comparison returned address
with zero, while pci_dma_mapping_error() should be used.

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/intersil/prism54/islpci_dev.c
drivers/net/wireless/intersil/prism54/islpci_eth.c
drivers/net/wireless/intersil/prism54/islpci_mgt.c

index 931cf440ff187f432b2ced8a2e2411576ee3cc67..84a42012aeae096806eb0900561f12803707d448 100644 (file)
@@ -707,7 +707,9 @@ islpci_alloc_memory(islpci_private *priv)
                    pci_map_single(priv->pdev, (void *) skb->data,
                                   MAX_FRAGMENT_SIZE_RX + 2,
                                   PCI_DMA_FROMDEVICE);
-               if (!priv->pci_map_rx_address[counter]) {
+               if (pci_dma_mapping_error(priv->pdev,
+                                         priv->pci_map_rx_address[counter])) {
+                       priv->pci_map_rx_address[counter] = 0;
                        /* error mapping the buffer to device
                           accessible memory address */
                        printk(KERN_ERR "failed to map skb DMA'able\n");
index 674658f2e6ef4bf8589bb9d35b28f39aa6bd32b7..d83f6332019eed19d20c04950ef18e419fd192e9 100644 (file)
@@ -190,7 +190,7 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev)
        pci_map_address = pci_map_single(priv->pdev,
                                         (void *) skb->data, skb->len,
                                         PCI_DMA_TODEVICE);
-       if (unlikely(pci_map_address == 0)) {
+       if (pci_dma_mapping_error(priv->pdev, pci_map_address)) {
                printk(KERN_WARNING "%s: cannot map buffer to PCI\n",
                       ndev->name);
                goto drop_free;
@@ -448,7 +448,8 @@ islpci_eth_receive(islpci_private *priv)
                    pci_map_single(priv->pdev, (void *) skb->data,
                                   MAX_FRAGMENT_SIZE_RX + 2,
                                   PCI_DMA_FROMDEVICE);
-               if (unlikely(!priv->pci_map_rx_address[index])) {
+               if (pci_dma_mapping_error(priv->pdev,
+                                         priv->pci_map_rx_address[index])) {
                        /* error mapping the buffer to device accessible memory address */
                        DEBUG(SHOW_ERROR_MESSAGES,
                              "Error mapping DMA address\n");
index 0de14dfa68cc3cb675165135aa4762edcff35d80..53d7a1705e8eaf0a8b1241de24fcf4fb39590ba4 100644 (file)
@@ -130,7 +130,7 @@ islpci_mgmt_rx_fill(struct net_device *ndev)
                        buf->pci_addr = pci_map_single(priv->pdev, buf->mem,
                                                       MGMT_FRAME_SIZE,
                                                       PCI_DMA_FROMDEVICE);
-                       if (!buf->pci_addr) {
+                       if (pci_dma_mapping_error(priv->pdev, buf->pci_addr)) {
                                printk(KERN_WARNING
                                       "Failed to make memory DMA'able.\n");
                                return -ENOMEM;
@@ -217,7 +217,7 @@ islpci_mgt_transmit(struct net_device *ndev, int operation, unsigned long oid,
        err = -ENOMEM;
        buf.pci_addr = pci_map_single(priv->pdev, buf.mem, frag_len,
                                      PCI_DMA_TODEVICE);
-       if (!buf.pci_addr) {
+       if (pci_dma_mapping_error(priv->pdev, buf.pci_addr)) {
                printk(KERN_WARNING "%s: cannot map PCI memory for mgmt\n",
                       ndev->name);
                goto error_free;