Added a pci_dma_mapping_error() call to check for mapping errors before
further using the dma handle. The previously allocated skb is freed in
case of a mapping error. Unchecked dma handles were found using Coccinelle:

@rule1@
expression e1;
identifier x;
@@

*x = pci_map_single(...);
 ... when != pci_dma_mapping_error(e1,x)

Signed-off-by: Tina Johnson <[email protected]>
Acked-by: Julia Lawall <[email protected]>
---
 drivers/infiniband/hw/amso1100/c2.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/amso1100/c2.c 
b/drivers/infiniband/hw/amso1100/c2.c
index 766a71c..c623e82 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -231,6 +231,10 @@ static inline int c2_rx_alloc(struct c2_port *c2_port, 
struct c2_element *elem)
        mapaddr =
            pci_map_single(c2dev->pcidev, skb->data, maplen,
                           PCI_DMA_FROMDEVICE);
+       if (pci_dma_mapping_error(c2dev->pcidev, mapaddr)) {
+               dev_kfree_skb(skb);
+               return -ENOMEM;
+       }
 
        /* Set the sk_buff RXP_header to RXP_HRXD_READY */
        rxp_hdr = (struct c2_rxp_hdr *) skb->data;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to