Commit c10e4caf authored by Iyappan Subramanian's avatar Iyappan Subramanian Committed by 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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment