Commit 91c77550 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by David S. Miller

net: sh_eth: fix up the buffer pointers

After freeing the buffer, the driver should change the value of
the pointer to NULL.
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2ecbb783
...@@ -788,6 +788,7 @@ static void sh_eth_ring_free(struct net_device *ndev) ...@@ -788,6 +788,7 @@ static void sh_eth_ring_free(struct net_device *ndev)
} }
} }
kfree(mdp->rx_skbuff); kfree(mdp->rx_skbuff);
mdp->rx_skbuff = NULL;
/* Free Tx skb ringbuffer */ /* Free Tx skb ringbuffer */
if (mdp->tx_skbuff) { if (mdp->tx_skbuff) {
...@@ -797,6 +798,7 @@ static void sh_eth_ring_free(struct net_device *ndev) ...@@ -797,6 +798,7 @@ static void sh_eth_ring_free(struct net_device *ndev)
} }
} }
kfree(mdp->tx_skbuff); kfree(mdp->tx_skbuff);
mdp->tx_skbuff = NULL;
} }
/* format skb and descriptor buffer */ /* format skb and descriptor buffer */
...@@ -933,10 +935,31 @@ static int sh_eth_ring_init(struct net_device *ndev) ...@@ -933,10 +935,31 @@ static int sh_eth_ring_init(struct net_device *ndev)
skb_ring_free: skb_ring_free:
/* Free Rx and Tx skb ring buffer */ /* Free Rx and Tx skb ring buffer */
sh_eth_ring_free(ndev); sh_eth_ring_free(ndev);
mdp->tx_ring = NULL;
mdp->rx_ring = NULL;
return ret; return ret;
} }
static void sh_eth_free_dma_buffer(struct sh_eth_private *mdp)
{
int ringsize;
if (mdp->rx_ring) {
ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE;
dma_free_coherent(NULL, ringsize, mdp->rx_ring,
mdp->rx_desc_dma);
mdp->rx_ring = NULL;
}
if (mdp->tx_ring) {
ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE;
dma_free_coherent(NULL, ringsize, mdp->tx_ring,
mdp->tx_desc_dma);
mdp->tx_ring = NULL;
}
}
static int sh_eth_dev_init(struct net_device *ndev) static int sh_eth_dev_init(struct net_device *ndev)
{ {
int ret = 0; int ret = 0;
...@@ -1677,7 +1700,6 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -1677,7 +1700,6 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
static int sh_eth_close(struct net_device *ndev) static int sh_eth_close(struct net_device *ndev)
{ {
struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_private *mdp = netdev_priv(ndev);
int ringsize;
netif_stop_queue(ndev); netif_stop_queue(ndev);
...@@ -1700,12 +1722,7 @@ static int sh_eth_close(struct net_device *ndev) ...@@ -1700,12 +1722,7 @@ static int sh_eth_close(struct net_device *ndev)
sh_eth_ring_free(ndev); sh_eth_ring_free(ndev);
/* free DMA buffer */ /* free DMA buffer */
ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; sh_eth_free_dma_buffer(mdp);
dma_free_coherent(NULL, ringsize, mdp->rx_ring, mdp->rx_desc_dma);
/* free DMA buffer */
ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE;
dma_free_coherent(NULL, ringsize, mdp->tx_ring, mdp->tx_desc_dma);
pm_runtime_put_sync(&mdp->pdev->dev); pm_runtime_put_sync(&mdp->pdev->dev);
......
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