* [PATCH v2] drivers: atm: eni: Add pci_dma_mapping_error() call
@ 2014-11-20 10:24 Tina Johnson
2014-11-21 20:03 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Tina Johnson @ 2014-11-20 10:24 UTC (permalink / raw)
To: chas; +Cc: linux-atm-general, netdev, linux-kernel, julia.lawall, Tina Johnson
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>
---
v2: *Removed jump to trouble label
*Added a new label dma_map_error
drivers/atm/eni.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index d65975a..c7fab3e 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,
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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] drivers: atm: eni: Add pci_dma_mapping_error() call
2014-11-20 10:24 [PATCH v2] drivers: atm: eni: Add pci_dma_mapping_error() call Tina Johnson
@ 2014-11-21 20:03 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-11-21 20:03 UTC (permalink / raw)
To: tinajohnson.1234
Cc: chas, linux-atm-general, netdev, linux-kernel, julia.lawall
From: Tina Johnson <tinajohnson.1234@gmail.com>
Date: Thu, 20 Nov 2014 15:54:54 +0530
> 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>
> ---
> v2: *Removed jump to trouble label
> *Added a new label dma_map_error
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-21 20:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-20 10:24 [PATCH v2] drivers: atm: eni: Add pci_dma_mapping_error() call Tina Johnson
2014-11-21 20:03 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).