diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 1d29082d94ac32886472963b4e48c4283ed1bf80..f0b9a1e1db46d18a3fdeded05ee8bba2187b6151 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -315,13 +315,29 @@ void can_get_echo_skb(struct net_device *dev, int idx) { struct can_priv *priv = netdev_priv(dev); - if ((dev->flags & IFF_ECHO) && priv->echo_skb[idx]) { + if (priv->echo_skb[idx]) { netif_rx(priv->echo_skb[idx]); priv->echo_skb[idx] = NULL; } } EXPORT_SYMBOL_GPL(can_get_echo_skb); +/* + * Remove the skb from the stack and free it. + * + * The function is typically called when TX failed. + */ +void can_free_echo_skb(struct net_device *dev, int idx) +{ + struct can_priv *priv = netdev_priv(dev); + + if (priv->echo_skb[idx]) { + kfree_skb(priv->echo_skb[idx]); + priv->echo_skb[idx] = NULL; + } +} +EXPORT_SYMBOL_GPL(can_free_echo_skb); + /* * CAN device restart for bus-off recovery */ diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 4a37a56f6cdda1dee7f6a84dd6b99e82cce59b06..5824b20b5fcbca849c04d459d34ed22a619eb207 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -66,5 +66,6 @@ void can_bus_off(struct net_device *dev); void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx); void can_get_echo_skb(struct net_device *dev, int idx); +void can_free_echo_skb(struct net_device *dev, int idx); #endif /* CAN_DEV_H */