Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91785de6 authored by Stephane Grosjean's avatar Stephane Grosjean Committed by Marc Kleine-Budde
Browse files

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: 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 12147edc
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -258,21 +258,18 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
	/* if this frame is an echo, */
	if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) &&
	    !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) {
		int n;
		unsigned long flags;

		spin_lock_irqsave(&priv->echo_lock, flags);
		n = can_get_echo_skb(priv->ndev, msg->client);
		can_get_echo_skb(priv->ndev, msg->client);
		spin_unlock_irqrestore(&priv->echo_lock, flags);

		/* count bytes of the echo instead of skb */
		stats->tx_bytes += cf_len;
		stats->tx_packets++;

		if (n) {
			/* restart tx queue only if a slot is free */
		/* restart tx queue (a slot is free) */
		netif_wake_queue(priv->ndev);
		}

		return 0;
	}