diff mbox

[net] tulip: Properly check dma mapping result

Message ID 1371151888-12138-1-git-send-email-nhorman@tuxdriver.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Neil Horman June 13, 2013, 7:31 p.m. UTC
Tulip throws an error when dma debugging is enabled, as it doesn't properly
check dma mapping results with dma_mapping_error() durring tx ring refills.

Easy fix, just add it in, and drop the frame if the mapping is bad

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Grant Grundler <grundler@parisc-linux.org>
CC: "David S. Miller" <davem@davemloft.net>
---
 drivers/net/ethernet/dec/tulip/interrupt.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Grant Grundler June 13, 2013, 10:26 p.m. UTC | #1
On Thu, Jun 13, 2013 at 12:31 PM, Neil Horman <nhorman@tuxdriver.com> wrote:
> Tulip throws an error when dma debugging is enabled, as it doesn't properly
> check dma mapping results with dma_mapping_error() durring tx ring refills.
>
> Easy fix, just add it in, and drop the frame if the mapping is bad
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Grant Grundler <grundler@parisc-linux.org>

LGTM. thanks!

Reviewed-by: Grant Grundler <grundler@parisc-linux.org>

FYA: the original DMA mapping interface that was introduce in 2.4 did
not return errors. It would panic the system. The reasoning at the
time was (I'm paraphrasing): "Driver writers won't check the erorr or
handle it correctly so don't make it more complicated.

cheers,
grant

> CC: "David S. Miller" <davem@davemloft.net>
> ---
>  drivers/net/ethernet/dec/tulip/interrupt.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/dec/tulip/interrupt.c b/drivers/net/ethernet/dec/tulip/interrupt.c
> index 28a5e42..92306b3 100644
> --- a/drivers/net/ethernet/dec/tulip/interrupt.c
> +++ b/drivers/net/ethernet/dec/tulip/interrupt.c
> @@ -76,6 +76,12 @@ int tulip_refill_rx(struct net_device *dev)
>
>                         mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
>                                                  PCI_DMA_FROMDEVICE);
> +                       if (dma_mapping_error(&tp->pdev->dev, mapping)) {
> +                               dev_kfree_skb(skb);
> +                               tp->rx_buffers[entry].skb = NULL;
> +                               break;
> +                       }
> +
>                         tp->rx_buffers[entry].mapping = mapping;
>
>                         tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping);
> --
> 1.8.1.4
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller June 14, 2013, 12:10 a.m. UTC | #2
From: Neil Horman <nhorman@tuxdriver.com>
Date: Thu, 13 Jun 2013 15:31:28 -0400

> Tulip throws an error when dma debugging is enabled, as it doesn't properly
> check dma mapping results with dma_mapping_error() durring tx ring refills.
> 
> Easy fix, just add it in, and drop the frame if the mapping is bad
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/dec/tulip/interrupt.c b/drivers/net/ethernet/dec/tulip/interrupt.c
index 28a5e42..92306b3 100644
--- a/drivers/net/ethernet/dec/tulip/interrupt.c
+++ b/drivers/net/ethernet/dec/tulip/interrupt.c
@@ -76,6 +76,12 @@  int tulip_refill_rx(struct net_device *dev)
 
 			mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
 						 PCI_DMA_FROMDEVICE);
+			if (dma_mapping_error(&tp->pdev->dev, mapping)) {
+				dev_kfree_skb(skb);
+				tp->rx_buffers[entry].skb = NULL;
+				break;
+			}
+
 			tp->rx_buffers[entry].mapping = mapping;
 
 			tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping);