Skip to contentSkip to conversation

hip04_eth: fix missing error handle for build_skb failed

PATCH Applied Weidong Wang 3 participants 3 messages Jan 13, 2016

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

PATCH 1/1 hip04_eth: fix missing error handle for build_skb failed

when build_skb failed, we should goto refill the buffer.

---
 drivers/net/ethernet/hisilicon/hip04_eth.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hip04_eth.c +4 -1
index 3b39fdd..417f131 100644
@@ -500,8 +500,10 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
 	while (cnt && !last) {
 		buf = priv->rx_buf[priv->rx_head];
 		skb = build_skb(buf, priv->rx_buf_size);
-		if (unlikely(!skb))
+		if (unlikely(!skb)) {
 			net_dbg_ratelimited("build_skb failed\n");
+			goto refill;
+		}
 
 		dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head],
 				 RX_BUF_SIZE, DMA_FROM_DEVICE);
@@ -528,6 +530,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
 			rx++;
 		}
 
+refill:
 		buf = netdev_alloc_frag(priv->rx_buf_size);
 		if (!buf)
 			goto done;
Signature · 1 line
1.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Weidong Wang

when build_skb failed, we should goto refill the buffer.

---

Quoted 28 lines
 drivers/net/ethernet/hisilicon/hip04_eth.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hip04_eth.c +4 -1
index 3b39fdd..417f131 100644
@@ -500,8 +500,10 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
 	while (cnt && !last) {
 		buf = priv->rx_buf[priv->rx_head];
 		skb = build_skb(buf, priv->rx_buf_size);
-		if (unlikely(!skb))
+		if (unlikely(!skb)) {
 			net_dbg_ratelimited("build_skb failed\n");
+			goto refill;
+		}
 
 		dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head],
 				 RX_BUF_SIZE, DMA_FROM_DEVICE);
@@ -528,6 +530,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
 			rx++;
 		}
 
+refill:
 		buf = netdev_alloc_frag(priv->rx_buf_size);
 		if (!buf)
 			goto done;