Skip to contentSkip to conversation

drivers: infiniband: hw: Add pci_dma_mapping_error() call

PATCH New Tina Johnson 1 participant 1 message Nov 29, 2014 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: infiniband: hw: Add pci_dma_mapping_error() call

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)

---
 drivers/infiniband/hw/amso1100/c2.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/infiniband/hw/amso1100/c2.c +4 -0
index 766a71c..c623e82 100644
@@ -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;
Signature · 6 lines
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