Patch "can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames" has been added to the 5.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames

to the 5.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     can-dev-__can_get_echo_skb-fix-real-payload-length-r.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 852196da891535003d3192dfbf57584c046a6f3c
Author: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>
Date:   Tue Oct 20 08:44:43 2020 +0200

    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@xxxxxxxxxx>
    Signed-off-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20201020064443.80164-1-socketcan@xxxxxxxxxxxx
    Fixes: cf5046b309b3 ("can: dev: let can_get_echo_skb() return dlc of CAN frame")
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index e291fda395a0f..d5e52ffc7ed25 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -486,9 +486,13 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
 		 */
 		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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux