[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <6ad9fef330a2c9b59139621efbb7c77e746d9f25.1487187192.git.pavel.belous@aquantia.com>
Date: Wed, 15 Feb 2017 23:01:18 +0300
From: Pavel Belous <Pavel.Belous@...antia.com>
To: "David S . Miller" <davem@...emloft.net>
Cc: netdev@...r.kernel.org,
Simon Edelhaus <Simon.Edelhaus@...antia.com>,
Alexey Andriyanov <Alexey.Andriyanov@...antia.com>,
Lino Sanfilippo <LinoSanfilippo@....de>,
Pavel Belous <pavel.belous@...antia.com>
Subject: [PATCH net-next 10/13] net: ethernet: aquantia: Checking for success dma_map_single.
From: Pavel Belous <pavel.belous@...antia.com>
Dma mapping can fail. We should check the result.
Signed-off-by: Pavel Belous <pavel.belous@...antia.com>
---
drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index daed4c1..7000b9f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -476,11 +476,15 @@ static unsigned int aq_nic_map_skb_frag(struct aq_nic_s *self,
unsigned int ret = 0U;
unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
unsigned int frag_count = 0U;
+ struct device *dev = aq_nic_get_dev(self);
dx->flags = 0U;
dx->len = skb_headlen(skb);
- dx->pa = dma_map_single(aq_nic_get_dev(self), skb->data, dx->len,
- DMA_TO_DEVICE);
+ dx->pa = dma_map_single(dev, skb->data, dx->len, DMA_TO_DEVICE);
+
+ if (unlikely(dma_mapping_error(dev, dx->pa)))
+ goto err_exit;
+
dx->len_pkt = skb->len;
dx->is_sop = 1U;
dx->is_mapped = 1U;
@@ -502,8 +506,10 @@ static unsigned int aq_nic_map_skb_frag(struct aq_nic_s *self,
frag_len = skb_frag_size(frag);
- frag_pa = skb_frag_dma_map(aq_nic_get_dev(self), frag, 0,
+ frag_pa = skb_frag_dma_map(dev, frag, 0,
frag_len, DMA_TO_DEVICE);
+ if (unlikely(dma_mapping_error(dev, frag_pa)))
+ goto err_exit;
while (frag_len > AQ_CFG_TX_FRAME_MAX) {
++dx;
@@ -529,6 +535,7 @@ static unsigned int aq_nic_map_skb_frag(struct aq_nic_s *self,
dx->is_eop = 1U;
dx->skb = skb;
+err_exit:
return ret;
}
--
2.7.4
Powered by blists - more mailing lists