]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bgmac: fix a missing check for build_skb
authorwangweidong <wangweidong1@huawei.com>
Wed, 13 Jan 2016 03:06:41 +0000 (11:06 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Jan 2016 05:24:14 +0000 (00:24 -0500)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bgmac.c

index c7798d360512363f3e18f0e3e3dd1cdef5d4fc7f..397415217125e678746e9693dbf53b9aeb1b4896 100644 (file)
@@ -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 +