diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2012-06-26 16:00:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-27 04:24:16 -0400 |
commit | 91c77550000a7d888aaf9f9ac13e3e3485d18560 (patch) | |
tree | 063cd97e431d239421118532625e8ebe05bdd07d /drivers/net/ethernet/renesas | |
parent | 2ecbb783c3bf5a63f555c39deef308dcc1902b7f (diff) |
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: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/renesas')
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 43e76d21e57f..2dd2ff5ecb5a 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
@@ -788,6 +788,7 @@ static void sh_eth_ring_free(struct net_device *ndev) | |||
788 | } | 788 | } |
789 | } | 789 | } |
790 | kfree(mdp->rx_skbuff); | 790 | kfree(mdp->rx_skbuff); |
791 | mdp->rx_skbuff = NULL; | ||
791 | 792 | ||
792 | /* Free Tx skb ringbuffer */ | 793 | /* Free Tx skb ringbuffer */ |
793 | if (mdp->tx_skbuff) { | 794 | if (mdp->tx_skbuff) { |
@@ -797,6 +798,7 @@ static void sh_eth_ring_free(struct net_device *ndev) | |||
797 | } | 798 | } |
798 | } | 799 | } |
799 | kfree(mdp->tx_skbuff); | 800 | kfree(mdp->tx_skbuff); |
801 | mdp->tx_skbuff = NULL; | ||
800 | } | 802 | } |
801 | 803 | ||
802 | /* format skb and descriptor buffer */ | 804 | /* format skb and descriptor buffer */ |
@@ -933,10 +935,31 @@ desc_ring_free: | |||
933 | skb_ring_free: | 935 | skb_ring_free: |
934 | /* Free Rx and Tx skb ring buffer */ | 936 | /* Free Rx and Tx skb ring buffer */ |
935 | sh_eth_ring_free(ndev); | 937 | sh_eth_ring_free(ndev); |
938 | mdp->tx_ring = NULL; | ||
939 | mdp->rx_ring = NULL; | ||
936 | 940 | ||
937 | return ret; | 941 | return ret; |
938 | } | 942 | } |
939 | 943 | ||
944 | static void sh_eth_free_dma_buffer(struct sh_eth_private *mdp) | ||
945 | { | ||
946 | int ringsize; | ||
947 | |||
948 | if (mdp->rx_ring) { | ||
949 | ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; | ||
950 | dma_free_coherent(NULL, ringsize, mdp->rx_ring, | ||
951 | mdp->rx_desc_dma); | ||
952 | mdp->rx_ring = NULL; | ||
953 | } | ||
954 | |||
955 | if (mdp->tx_ring) { | ||
956 | ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; | ||
957 | dma_free_coherent(NULL, ringsize, mdp->tx_ring, | ||
958 | mdp->tx_desc_dma); | ||
959 | mdp->tx_ring = NULL; | ||
960 | } | ||
961 | } | ||
962 | |||
940 | static int sh_eth_dev_init(struct net_device *ndev) | 963 | static int sh_eth_dev_init(struct net_device *ndev) |
941 | { | 964 | { |
942 | int ret = 0; | 965 | int ret = 0; |
@@ -1677,7 +1700,6 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
1677 | static int sh_eth_close(struct net_device *ndev) | 1700 | static int sh_eth_close(struct net_device *ndev) |
1678 | { | 1701 | { |
1679 | struct sh_eth_private *mdp = netdev_priv(ndev); | 1702 | struct sh_eth_private *mdp = netdev_priv(ndev); |
1680 | int ringsize; | ||
1681 | 1703 | ||
1682 | netif_stop_queue(ndev); | 1704 | netif_stop_queue(ndev); |
1683 | 1705 | ||
@@ -1700,12 +1722,7 @@ static int sh_eth_close(struct net_device *ndev) | |||
1700 | sh_eth_ring_free(ndev); | 1722 | sh_eth_ring_free(ndev); |
1701 | 1723 | ||
1702 | /* free DMA buffer */ | 1724 | /* free DMA buffer */ |
1703 | ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; | 1725 | sh_eth_free_dma_buffer(mdp); |
1704 | dma_free_coherent(NULL, ringsize, mdp->rx_ring, mdp->rx_desc_dma); | ||
1705 | |||
1706 | /* free DMA buffer */ | ||
1707 | ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; | ||
1708 | dma_free_coherent(NULL, ringsize, mdp->tx_ring, mdp->tx_desc_dma); | ||
1709 | 1726 | ||
1710 | pm_runtime_put_sync(&mdp->pdev->dev); | 1727 | pm_runtime_put_sync(&mdp->pdev->dev); |
1711 | 1728 | ||