diff options
author | Denis Kirjanov <dkirjanov@hera.kernel.org> | 2010-07-08 06:24:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-09 02:39:49 -0400 |
commit | 301e9d96bf65292f916a3936d63c504ac7792ee6 (patch) | |
tree | d8262d45ab7bbd348f7993cad9f7704574c008f8 /drivers/net | |
parent | 47562e5d325af9ce5306bce53eb7cdd353fe46be (diff) |
ll_temac: fix DMA resources leak
V2: Check pointers before releasing resources.
Fix DMA resources leak.
Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ll_temac_main.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c index fa303c881a48..b57d0ff52519 100644 --- a/drivers/net/ll_temac_main.c +++ b/drivers/net/ll_temac_main.c | |||
@@ -193,6 +193,35 @@ static int temac_dcr_setup(struct temac_local *lp, struct of_device *op, | |||
193 | #endif | 193 | #endif |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * * temac_dma_bd_release - Release buffer descriptor rings | ||
197 | */ | ||
198 | static void temac_dma_bd_release(struct net_device *ndev) | ||
199 | { | ||
200 | struct temac_local *lp = netdev_priv(ndev); | ||
201 | int i; | ||
202 | |||
203 | for (i = 0; i < RX_BD_NUM; i++) { | ||
204 | if (!lp->rx_skb[i]) | ||
205 | break; | ||
206 | else { | ||
207 | dma_unmap_single(ndev->dev.parent, lp->rx_bd_v[i].phys, | ||
208 | XTE_MAX_JUMBO_FRAME_SIZE, DMA_FROM_DEVICE); | ||
209 | dev_kfree_skb(lp->rx_skb[i]); | ||
210 | } | ||
211 | } | ||
212 | if (lp->rx_bd_v) | ||
213 | dma_free_coherent(ndev->dev.parent, | ||
214 | sizeof(*lp->rx_bd_v) * RX_BD_NUM, | ||
215 | lp->rx_bd_v, lp->rx_bd_p); | ||
216 | if (lp->tx_bd_v) | ||
217 | dma_free_coherent(ndev->dev.parent, | ||
218 | sizeof(*lp->tx_bd_v) * TX_BD_NUM, | ||
219 | lp->tx_bd_v, lp->tx_bd_p); | ||
220 | if (lp->rx_skb) | ||
221 | kfree(lp->rx_skb); | ||
222 | } | ||
223 | |||
224 | /** | ||
196 | * temac_dma_bd_init - Setup buffer descriptor rings | 225 | * temac_dma_bd_init - Setup buffer descriptor rings |
197 | */ | 226 | */ |
198 | static int temac_dma_bd_init(struct net_device *ndev) | 227 | static int temac_dma_bd_init(struct net_device *ndev) |
@@ -275,6 +304,7 @@ static int temac_dma_bd_init(struct net_device *ndev) | |||
275 | return 0; | 304 | return 0; |
276 | 305 | ||
277 | out: | 306 | out: |
307 | temac_dma_bd_release(ndev); | ||
278 | return -ENOMEM; | 308 | return -ENOMEM; |
279 | } | 309 | } |
280 | 310 | ||
@@ -858,6 +888,8 @@ static int temac_stop(struct net_device *ndev) | |||
858 | phy_disconnect(lp->phy_dev); | 888 | phy_disconnect(lp->phy_dev); |
859 | lp->phy_dev = NULL; | 889 | lp->phy_dev = NULL; |
860 | 890 | ||
891 | temac_dma_bd_release(ndev); | ||
892 | |||
861 | return 0; | 893 | return 0; |
862 | } | 894 | } |
863 | 895 | ||