Commit fee6a892 authored by Stephane Grosjean's avatar Stephane Grosjean Committed by Marc Kleine-Budde

can: peak_usb: fix potential double kfree_skb()

When closing the CAN device while tx skbs are inflight, echo skb could
be released twice. By calling close_candev() before unlinking all
pending tx urbs, then the internal echo_skb[] array is fully and
correctly cleared before the USB write callback and, therefore,
can_get_echo_skb() are called, for each aborted URB.

Fixes: bb478555 ("can: usb: PEAK-System Technik USB adapters driver core")
Signed-off-by: default avatarStephane Grosjean <s.grosjean@peak-system.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 5f186c25
...@@ -568,16 +568,16 @@ static int peak_usb_ndo_stop(struct net_device *netdev) ...@@ -568,16 +568,16 @@ static int peak_usb_ndo_stop(struct net_device *netdev)
dev->state &= ~PCAN_USB_STATE_STARTED; dev->state &= ~PCAN_USB_STATE_STARTED;
netif_stop_queue(netdev); netif_stop_queue(netdev);
close_candev(netdev);
dev->can.state = CAN_STATE_STOPPED;
/* unlink all pending urbs and free used memory */ /* unlink all pending urbs and free used memory */
peak_usb_unlink_all_urbs(dev); peak_usb_unlink_all_urbs(dev);
if (dev->adapter->dev_stop) if (dev->adapter->dev_stop)
dev->adapter->dev_stop(dev); dev->adapter->dev_stop(dev);
close_candev(netdev);
dev->can.state = CAN_STATE_STOPPED;
/* can set bus off now */ /* can set bus off now */
if (dev->adapter->dev_set_bus) { if (dev->adapter->dev_set_bus) {
int err = dev->adapter->dev_set_bus(dev, 0); int err = dev->adapter->dev_set_bus(dev, 0);
......
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