dp83640: free packet queues on remove
Richard Cochran [Fri, 21 Oct 2011 00:49:17 +0000 (00:49 +0000)]
commit 8b3408f8ee994973869d8ba32c5bf482bc4ddca4 upstream.

If the PHY should disappear (for example, on an USB Ethernet MAC), then
the driver would leak any undelivered time stamp packets. This commit
fixes the issue by calling the appropriate functions to free any packets
left in the transmit and receive queues.

The driver first appeared in v3.0.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

drivers/net/phy/dp83640.c

index edd7304..226f58f 100644 (file)
@@ -875,6 +875,7 @@ static void dp83640_remove(struct phy_device *phydev)
        struct dp83640_clock *clock;
        struct list_head *this, *next;
        struct dp83640_private *tmp, *dp83640 = phydev->priv;
+       struct sk_buff *skb;
 
        if (phydev->addr == BROADCAST_ADDR)
                return;
@@ -882,6 +883,12 @@ static void dp83640_remove(struct phy_device *phydev)
        enable_status_frames(phydev, false);
        cancel_work_sync(&dp83640->ts_work);
 
+       while ((skb = skb_dequeue(&dp83640->rx_queue)) != NULL)
+               kfree_skb(skb);
+
+       while ((skb = skb_dequeue(&dp83640->tx_queue)) != NULL)
+               skb_complete_tx_timestamp(skb, NULL);
+
        clock = dp83640_clock_get(dp83640->clock);
 
        if (dp83640 == clock->chosen) {