Skip to contentSkip to conversation

drivers: atm: eni: Add pci_dma_mapping_error() call

PATCH Applied Tina Johnson 2 participants 2 messages Nov 20, 2014 – Nov 21, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drivers: atm: eni: Add pci_dma_mapping_error() call

Added a pci_dma_mapping_error() call to check for mapping errors before further using the dma handle. In case of error, control goes to a new label where the incoming skb is freed. Unchecked dma handles were found using Coccinelle:

@rule1@
expression e1;
identifier x;
@@

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

---
v2: *Removed jump to trouble label
*Added a new label dma_map_error

 drivers/atm/eni.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/atm/eni.c +3 -0
index d65975a..c7fab3e 100644
@@ -356,6 +356,8 @@ static int do_rx_dma(struct atm_vcc *vcc,struct sk_buff *skb,
 	if (skb) {
 		paddr = pci_map_single(eni_dev->pci_dev,skb->data,skb->len,
 		    PCI_DMA_FROMDEVICE);
+		if (pci_dma_mapping_error(eni_dev->pci_dev, paddr))
+			goto dma_map_error;
 		ENI_PRV_PADDR(skb) = paddr;
 		if (paddr & 3)
 			printk(KERN_CRIT DEV_LABEL "(itf %d): VCI %d has "
@@ -481,6 +483,7 @@ trouble:
 	if (paddr)
 		pci_unmap_single(eni_dev->pci_dev,paddr,skb->len,
 		    PCI_DMA_FROMDEVICE);
+dma_map_error:
 	if (skb) dev_kfree_skb_irq(skb);
 	return -1;
 }
Signature · 1 line
1.7.10.4
maintainer Applied
#1 lore raw

From: Tina Johnson <[email protected]>
Date: Thu, 20 Nov 2014 15:54:54 +0530

Quoted 10 lines

Added a pci_dma_mapping_error() call to check for mapping errors before further using the dma handle. In case of error, control goes to a new label where the incoming skb is freed. Unchecked dma handles were found using Coccinelle:

@rule1@
expression e1;
identifier x;
@@

Quoted 8 lines

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

---
v2: *Removed jump to trouble label
*Added a new label dma_map_error

Applied, thanks.