summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2020-10-20 08:44:43 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-18 18:24:58 +0100
commit0b7578675c2a87d8750d645819564c1d2f7d8044 (patch)
tree28ae986f9ea87f70b5f31e2bd8f6b3d1e047fbdb /drivers/net
parent248b71ce92d4f3a574b2537f9838f48e892618f4 (diff)
downloadlinux-stable-0b7578675c2a87d8750d645819564c1d2f7d8044.tar.gz
linux-stable-0b7578675c2a87d8750d645819564c1d2f7d8044.tar.bz2
linux-stable-0b7578675c2a87d8750d645819564c1d2f7d8044.zip
can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames
[ Upstream commit ed3320cec279407a86bc4c72edc4a39eb49165ec ] The can_get_echo_skb() function returns the number of received bytes to be used for netdev statistics. In the case of RTR frames we get a valid (potential non-zero) data length value which has to be passed for further operations. But on the wire RTR frames have no payload length. Therefore the value to be used in the statistics has to be zero for RTR frames. Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201020064443.80164-1-socketcan@hartkopp.net Fixes: cf5046b309b3 ("can: dev: let can_get_echo_skb() return dlc of CAN frame") Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/can/dev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 3c0f141262ad..9579dae54af2 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -439,9 +439,13 @@ struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8
*/
struct sk_buff *skb = priv->echo_skb[idx];
struct canfd_frame *cf = (struct canfd_frame *)skb->data;
- u8 len = cf->len;
- *len_ptr = len;
+ /* get the real payload length for netdev statistics */
+ if (cf->can_id & CAN_RTR_FLAG)
+ *len_ptr = 0;
+ else
+ *len_ptr = cf->len;
+
priv->echo_skb[idx] = NULL;
return skb;