提交 c10e4caf 编写于 作者: I Iyappan Subramanian 提交者: David S. Miller

net: xgene: fix possible NULL dereference in xgene_enet_free_desc_rings()

A NULL pointer dereference is possible for the argument ring->buf_pool
which is passed to xgene_enet_free_desc_ring(), as ring could be NULL.

And now since NULL pointers are being checked for before the calls to
xgene_enet_free_desc_ring(), might as well take advantage of them and
not call the function if the argument would be NULL.
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2ba5af42
...@@ -563,15 +563,21 @@ static void xgene_enet_free_desc_rings(struct xgene_enet_pdata *pdata) ...@@ -563,15 +563,21 @@ static void xgene_enet_free_desc_rings(struct xgene_enet_pdata *pdata)
struct xgene_enet_desc_ring *ring; struct xgene_enet_desc_ring *ring;
ring = pdata->tx_ring; ring = pdata->tx_ring;
if (ring && ring->cp_ring && ring->cp_ring->cp_skb) if (ring) {
devm_kfree(dev, ring->cp_ring->cp_skb); if (ring->cp_ring && ring->cp_ring->cp_skb)
xgene_enet_free_desc_ring(ring); devm_kfree(dev, ring->cp_ring->cp_skb);
xgene_enet_free_desc_ring(ring);
}
ring = pdata->rx_ring; ring = pdata->rx_ring;
if (ring && ring->buf_pool && ring->buf_pool->rx_skb) if (ring) {
devm_kfree(dev, ring->buf_pool->rx_skb); if (ring->buf_pool) {
xgene_enet_free_desc_ring(ring->buf_pool); if (ring->buf_pool->rx_skb)
xgene_enet_free_desc_ring(ring); devm_kfree(dev, ring->buf_pool->rx_skb);
xgene_enet_free_desc_ring(ring->buf_pool);
}
xgene_enet_free_desc_ring(ring);
}
} }
static struct xgene_enet_desc_ring *xgene_enet_create_desc_ring( static struct xgene_enet_desc_ring *xgene_enet_create_desc_ring(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册