diff options
author | Tina Johnson <tinajohnson.1234@gmail.com> | 2014-11-20 05:24:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-21 15:03:40 -0500 |
commit | 541675580ffcd098d746f7f713c7dbcc86744925 (patch) | |
tree | ee5f271c7fcaa51073bea01e02d1c435906978df /drivers/atm/eni.c | |
parent | 49ed2617a06abacaccd46fa88ae14c333baa15f0 (diff) |
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)
Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm/eni.c')
-rw-r--r-- | drivers/atm/eni.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index d65975aba4ec..c7fab3ee14ee 100644 --- a/drivers/atm/eni.c +++ b/drivers/atm/eni.c | |||
@@ -356,6 +356,8 @@ static int do_rx_dma(struct atm_vcc *vcc,struct sk_buff *skb, | |||
356 | if (skb) { | 356 | if (skb) { |
357 | paddr = pci_map_single(eni_dev->pci_dev,skb->data,skb->len, | 357 | paddr = pci_map_single(eni_dev->pci_dev,skb->data,skb->len, |
358 | PCI_DMA_FROMDEVICE); | 358 | PCI_DMA_FROMDEVICE); |
359 | if (pci_dma_mapping_error(eni_dev->pci_dev, paddr)) | ||
360 | goto dma_map_error; | ||
359 | ENI_PRV_PADDR(skb) = paddr; | 361 | ENI_PRV_PADDR(skb) = paddr; |
360 | if (paddr & 3) | 362 | if (paddr & 3) |
361 | printk(KERN_CRIT DEV_LABEL "(itf %d): VCI %d has " | 363 | printk(KERN_CRIT DEV_LABEL "(itf %d): VCI %d has " |
@@ -481,6 +483,7 @@ trouble: | |||
481 | if (paddr) | 483 | if (paddr) |
482 | pci_unmap_single(eni_dev->pci_dev,paddr,skb->len, | 484 | pci_unmap_single(eni_dev->pci_dev,paddr,skb->len, |
483 | PCI_DMA_FROMDEVICE); | 485 | PCI_DMA_FROMDEVICE); |
486 | dma_map_error: | ||
484 | if (skb) dev_kfree_skb_irq(skb); | 487 | if (skb) dev_kfree_skb_irq(skb); |
485 | return -1; | 488 | return -1; |
486 | } | 489 | } |