Commit 309fdb1c authored by Zhipeng Lu's avatar Zhipeng Lu Committed by David S. Miller

ethernet: atheros: fix a memleak in atl1e_setup_ring_resources

In the error handling of 'offset > adapter->ring_size', the
tx_ring->tx_buffer allocated by kzalloc should be freed,
instead of 'goto failed' instantly.

Fixes: a6a53252 ("atl1e: Atheros L1E Gigabit Ethernet driver")
Signed-off-by: default avatarZhipeng Lu <alexious@zju.edu.cn>
Reviewed-by: default avatarSuman Ghosh <sumang@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 19391a2c
...@@ -866,10 +866,13 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter) ...@@ -866,10 +866,13 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
netdev_err(adapter->netdev, "offset(%d) > ring size(%d) !!\n", netdev_err(adapter->netdev, "offset(%d) > ring size(%d) !!\n",
offset, adapter->ring_size); offset, adapter->ring_size);
err = -1; err = -1;
goto failed; goto free_buffer;
} }
return 0; return 0;
free_buffer:
kfree(tx_ring->tx_buffer);
tx_ring->tx_buffer = NULL;
failed: failed:
if (adapter->ring_vir_addr != NULL) { if (adapter->ring_vir_addr != NULL) {
dma_free_coherent(&pdev->dev, adapter->ring_size, dma_free_coherent(&pdev->dev, adapter->ring_size,
......
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