Commit f4e27944 authored by David S. Miller's avatar David S. Miller

Merge branch 'stmmac-dma-resources-fixes'

Christophe JAILLET says:

====================
net: stmmac: Fixes and cleanups in 'alloc_dma_[rt]x_desc_resources()'

These patchs are all related to 'alloc_dma_[rt]x_desc_resources()' functions.

The 2 first fix an error path where some resources are leaking. I've
separated them into 2 patches because the issues have been introduced by
2 deferent commits.

The 3rd patch is just a clean-up.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents fdf99b3f 62242260
...@@ -1449,7 +1449,7 @@ static void free_dma_rx_desc_resources(struct stmmac_priv *priv) ...@@ -1449,7 +1449,7 @@ static void free_dma_rx_desc_resources(struct stmmac_priv *priv)
static void free_dma_tx_desc_resources(struct stmmac_priv *priv) static void free_dma_tx_desc_resources(struct stmmac_priv *priv)
{ {
u32 tx_count = priv->plat->tx_queues_to_use; u32 tx_count = priv->plat->tx_queues_to_use;
u32 queue = 0; u32 queue;
/* Free TX queue resources */ /* Free TX queue resources */
for (queue = 0; queue < tx_count; queue++) { for (queue = 0; queue < tx_count; queue++) {
...@@ -1498,7 +1498,7 @@ static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv) ...@@ -1498,7 +1498,7 @@ static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv)
sizeof(dma_addr_t), sizeof(dma_addr_t),
GFP_KERNEL); GFP_KERNEL);
if (!rx_q->rx_skbuff_dma) if (!rx_q->rx_skbuff_dma)
return -ENOMEM; goto err_dma;
rx_q->rx_skbuff = kmalloc_array(DMA_RX_SIZE, rx_q->rx_skbuff = kmalloc_array(DMA_RX_SIZE,
sizeof(struct sk_buff *), sizeof(struct sk_buff *),
...@@ -1561,13 +1561,13 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) ...@@ -1561,13 +1561,13 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv)
sizeof(*tx_q->tx_skbuff_dma), sizeof(*tx_q->tx_skbuff_dma),
GFP_KERNEL); GFP_KERNEL);
if (!tx_q->tx_skbuff_dma) if (!tx_q->tx_skbuff_dma)
return -ENOMEM; goto err_dma;
tx_q->tx_skbuff = kmalloc_array(DMA_TX_SIZE, tx_q->tx_skbuff = kmalloc_array(DMA_TX_SIZE,
sizeof(struct sk_buff *), sizeof(struct sk_buff *),
GFP_KERNEL); GFP_KERNEL);
if (!tx_q->tx_skbuff) if (!tx_q->tx_skbuff)
goto err_dma_buffers; goto err_dma;
if (priv->extend_desc) { if (priv->extend_desc) {
tx_q->dma_etx = dma_zalloc_coherent(priv->device, tx_q->dma_etx = dma_zalloc_coherent(priv->device,
...@@ -1577,7 +1577,7 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) ...@@ -1577,7 +1577,7 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv)
&tx_q->dma_tx_phy, &tx_q->dma_tx_phy,
GFP_KERNEL); GFP_KERNEL);
if (!tx_q->dma_etx) if (!tx_q->dma_etx)
goto err_dma_buffers; goto err_dma;
} else { } else {
tx_q->dma_tx = dma_zalloc_coherent(priv->device, tx_q->dma_tx = dma_zalloc_coherent(priv->device,
DMA_TX_SIZE * DMA_TX_SIZE *
...@@ -1586,13 +1586,13 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) ...@@ -1586,13 +1586,13 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv)
&tx_q->dma_tx_phy, &tx_q->dma_tx_phy,
GFP_KERNEL); GFP_KERNEL);
if (!tx_q->dma_tx) if (!tx_q->dma_tx)
goto err_dma_buffers; goto err_dma;
} }
} }
return 0; return 0;
err_dma_buffers: err_dma:
free_dma_tx_desc_resources(priv); free_dma_tx_desc_resources(priv);
return ret; return ret;
......
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