070-v4.5-0001-bgmac-fix-a-missing-check-for-build_skb.patch 956 B

12345678910111213141516171819202122232425262728
  1. From f1640c3ddeec12804bc9a21feee85fc15aca95f6 Mon Sep 17 00:00:00 2001
  2. From: wangweidong <wangweidong1@huawei.com>
  3. Date: Wed, 13 Jan 2016 11:06:41 +0800
  4. Subject: [PATCH] bgmac: fix a missing check for build_skb
  5. when build_skb failed, it may occure a NULL pointer.
  6. So add a 'NULL check' for it.
  7. Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
  8. Signed-off-by: David S. Miller <davem@davemloft.net>
  9. ---
  10. drivers/net/ethernet/broadcom/bgmac.c | 5 +++++
  11. 1 file changed, 5 insertions(+)
  12. --- a/drivers/net/ethernet/broadcom/bgmac.c
  13. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  14. @@ -469,6 +469,11 @@ static int bgmac_dma_rx_read(struct bgma
  15. len -= ETH_FCS_LEN;
  16. skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
  17. + if (unlikely(skb)) {
  18. + bgmac_err(bgmac, "build_skb failed\n");
  19. + put_page(virt_to_head_page(buf));
  20. + break;
  21. + }
  22. skb_put(skb, BGMAC_RX_FRAME_OFFSET +
  23. BGMAC_RX_BUF_OFFSET + len);
  24. skb_pull(skb, BGMAC_RX_FRAME_OFFSET +