All of lore.kernel.org
 help / color / mirror / Atom feed
* bgmac: fix a missing check for build_skb
@ 2016-01-13  3:06 Weidong Wang
  2016-01-13  5:24 ` David Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Weidong Wang @ 2016-01-13  3:06 UTC (permalink / raw)
  To: David Miller, nbd, zajec5, hauke, Joe Perches, peter.senna
  Cc: netdev, linux-kernel

when build_skb failed, it may occure a NULL pointer.
So add a 'NULL check' for it.

Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
---
 drivers/net/ethernet/broadcom/bgmac.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 21e3c38..d75180a 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 			len -= ETH_FCS_LEN;

 			skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
+			if (unlikely(skb)) {
+				bgmac_err(bgmac, "build_skb failed\n");
+				put_page(virt_to_head_page(buf));
+				break;
+			}
 			skb_put(skb, BGMAC_RX_FRAME_OFFSET +
 				BGMAC_RX_BUF_OFFSET + len);
 			skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-01-14  2:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13  3:06 bgmac: fix a missing check for build_skb Weidong Wang
2016-01-13  5:24 ` David Miller
2016-01-13  8:34 ` Paolo Abeni
2016-01-13 10:25   ` Weidong Wang
2016-01-13 10:57     ` Felix Fietkau
2016-01-13 11:31       ` Weidong Wang
2016-01-13 15:34       ` David Miller
2016-01-13 11:53 ` [PATCH net-next v2] " Weidong Wang
2016-01-13 14:52   ` Eric Dumazet
2016-01-14  2:10     ` Weidong Wang
2016-01-13 12:10 ` Sergei Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.