Commit 80a71815 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

can: dev: can_put_echo_skb(): propagate error in case of errors

The function can_put_echo_skb() can fail for several reasons. It may
fail due to OOM, but when it fails it's usually due to locking problems
in the driver.

In order to help developing and debugging of new drivers propagate error
value in case of errors.

Link: https://lore.kernel.org/r/20200915223527.1417033-12-mkl@pengutronix.deSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 87245f1f
...@@ -434,7 +434,7 @@ static void can_flush_echo_skb(struct net_device *dev) ...@@ -434,7 +434,7 @@ static void can_flush_echo_skb(struct net_device *dev)
* of the device driver. The driver must protect access to * of the device driver. The driver must protect access to
* priv->echo_skb, if necessary. * priv->echo_skb, if necessary.
*/ */
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
unsigned int idx) unsigned int idx)
{ {
struct can_priv *priv = netdev_priv(dev); struct can_priv *priv = netdev_priv(dev);
...@@ -446,13 +446,13 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, ...@@ -446,13 +446,13 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
(skb->protocol != htons(ETH_P_CAN) && (skb->protocol != htons(ETH_P_CAN) &&
skb->protocol != htons(ETH_P_CANFD))) { skb->protocol != htons(ETH_P_CANFD))) {
kfree_skb(skb); kfree_skb(skb);
return; return 0;
} }
if (!priv->echo_skb[idx]) { if (!priv->echo_skb[idx]) {
skb = can_create_echo_skb(skb); skb = can_create_echo_skb(skb);
if (!skb) if (!skb)
return; return -ENOMEM;
/* make settings for echo to reduce code in irq context */ /* make settings for echo to reduce code in irq context */
skb->pkt_type = PACKET_BROADCAST; skb->pkt_type = PACKET_BROADCAST;
...@@ -465,7 +465,10 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, ...@@ -465,7 +465,10 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
/* locking problem with netif_stop_queue() ?? */ /* locking problem with netif_stop_queue() ?? */
netdev_err(dev, "%s: BUG! echo_skb %d is occupied!\n", __func__, idx); netdev_err(dev, "%s: BUG! echo_skb %d is occupied!\n", __func__, idx);
kfree_skb(skb); kfree_skb(skb);
return -EBUSY;
} }
return 0;
} }
EXPORT_SYMBOL_GPL(can_put_echo_skb); EXPORT_SYMBOL_GPL(can_put_echo_skb);
......
...@@ -201,7 +201,7 @@ void can_bus_off(struct net_device *dev); ...@@ -201,7 +201,7 @@ void can_bus_off(struct net_device *dev);
void can_change_state(struct net_device *dev, struct can_frame *cf, void can_change_state(struct net_device *dev, struct can_frame *cf,
enum can_state tx_state, enum can_state rx_state); enum can_state tx_state, enum can_state rx_state);
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
unsigned int idx); unsigned int idx);
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx,
u8 *len_ptr); u8 *len_ptr);
......
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