diff options
author | Stephane Grosjean <s.grosjean@peak-system.com> | 2017-12-07 10:13:43 -0500 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2017-12-08 04:51:53 -0500 |
commit | 91785de6f94b58c3fb6664609e3682f011bd28d2 (patch) | |
tree | 14c8fbdbe318d6425bcbd936d1e79cfe3271c1f0 | |
parent | 12147edc434c9e4c7c2f5fee2e5519b2e5ac34ce (diff) |
can: peak/pcie_fd: fix potential bug in restarting tx queue
Don't rely on can_get_echo_skb() return value to wake the network tx
queue up: can_get_echo_skb() returns 0 if the echo array slot was not
occupied, but also when the DLC of the released echo frame was 0.
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | drivers/net/can/peak_canfd/peak_canfd.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c index 85268be0c913..55513411a82e 100644 --- a/drivers/net/can/peak_canfd/peak_canfd.c +++ b/drivers/net/can/peak_canfd/peak_canfd.c | |||
@@ -258,21 +258,18 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv, | |||
258 | /* if this frame is an echo, */ | 258 | /* if this frame is an echo, */ |
259 | if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) && | 259 | if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) && |
260 | !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) { | 260 | !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) { |
261 | int n; | ||
262 | unsigned long flags; | 261 | unsigned long flags; |
263 | 262 | ||
264 | spin_lock_irqsave(&priv->echo_lock, flags); | 263 | spin_lock_irqsave(&priv->echo_lock, flags); |
265 | n = can_get_echo_skb(priv->ndev, msg->client); | 264 | can_get_echo_skb(priv->ndev, msg->client); |
266 | spin_unlock_irqrestore(&priv->echo_lock, flags); | 265 | spin_unlock_irqrestore(&priv->echo_lock, flags); |
267 | 266 | ||
268 | /* count bytes of the echo instead of skb */ | 267 | /* count bytes of the echo instead of skb */ |
269 | stats->tx_bytes += cf_len; | 268 | stats->tx_bytes += cf_len; |
270 | stats->tx_packets++; | 269 | stats->tx_packets++; |
271 | 270 | ||
272 | if (n) { | 271 | /* restart tx queue (a slot is free) */ |
273 | /* restart tx queue only if a slot is free */ | 272 | netif_wake_queue(priv->ndev); |
274 | netif_wake_queue(priv->ndev); | ||
275 | } | ||
276 | 273 | ||
277 | return 0; | 274 | return 0; |
278 | } | 275 | } |