From patchwork Fri Oct 16 17:22:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 11842145 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A446DC433DF for ; Fri, 16 Oct 2020 17:23:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58F5321D41 for ; Fri, 16 Oct 2020 17:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391535AbgJPRXL (ORCPT ); Fri, 16 Oct 2020 13:23:11 -0400 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:58009 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391301AbgJPRXL (ORCPT ); Fri, 16 Oct 2020 13:23:11 -0400 Received: from tomoyo.flets-east.jp ([153.230.197.127]) by mwinf5d44 with ME id ghNj2300m2lQRaH03hP5Kz; Fri, 16 Oct 2020 19:23:09 +0200 X-ME-Helo: tomoyo.flets-east.jp X-ME-Auth: bWFpbGhvbC52aW5jZW50QHdhbmFkb28uZnI= X-ME-Date: Fri, 16 Oct 2020 19:23:09 +0200 X-ME-IP: 153.230.197.127 From: Vincent Mailhol To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-can@vger.kernel.org, Marc Kleine-Budde , Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski Cc: Arunachalam Santhanam , Vincent Mailhol , Masahiro Yamada Subject: [PATCH v4 3/4] can: dev: __can_get_echo_skb(): fix the return length Date: Sat, 17 Oct 2020 02:22:11 +0900 Message-Id: <20201016172240.229359-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201016171402.229001-1-mailhol.vincent@wanadoo.fr> References: <20201016171402.229001-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The length of Remote Transmission Request (RTR) frames is always 0 bytes. The DLC represents the requested length, not the actual length of the RTR. But __can_get_echo_skb() returns the DLC value regardless. Apply get_can_len() function to retrieve the correct length. Signed-off-by: Vincent Mailhol --- Changes in v2 to v4: None --- drivers/net/can/dev.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 73cfcd7e9517..8f91d23c1ca7 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -507,14 +507,9 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) } if (priv->echo_skb[idx]) { - /* Using "struct canfd_frame::len" for the frame - * length is supported on both CAN and CANFD frames. - */ struct sk_buff *skb = priv->echo_skb[idx]; - struct canfd_frame *cf = (struct canfd_frame *)skb->data; - u8 len = cf->len; - *len_ptr = len; + *len_ptr = get_can_len(skb); priv->echo_skb[idx] = NULL; return skb;