Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3880351pxb; Tue, 17 Nov 2020 06:05:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQplfW/aCcYPQP9SINFEhpB7o8Wl7kYPUHrGwCC6oLG5MWAY/I5ffhPpXD+RRyO1jutgp0 X-Received: by 2002:a17:906:2683:: with SMTP id t3mr20164210ejc.414.1605621959399; Tue, 17 Nov 2020 06:05:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621959; cv=none; d=google.com; s=arc-20160816; b=eZ/EabibK7XogRFurUrK9J045YYgjKBNdK48lTtHVE8+30ohut1P8G7+WE+Dghlvyl zOEWPZaLBY8QuZySDnKSzXg5NtxLrds2l1H8knyMlm6s1tmqYvprxTbLQkZZoWAmqZca teescIlv6xoswP2vqJyUBw1Hkl63f2BqIK6+ji3pqmLPEO2i8P6kptojnv70HrEH8eYr +CJLJz7OgQm5Q9YnTkeDZsNjq2bi6YlXq2k9w1hIoUWVddUDCJdbC2tKzDuRmUUyQm3b 4USq8ELC3Rlf7JQm4312WGT2s5zJWtnQ8IcQcUxMrK63rWEtbyq/fSyGNdZx3dxJyZbl jlAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oKHgh7ZaN53iNeZJxTyUkcbuQ6HKGehb7BqW9IEdeGg=; b=CPiRZvkguy9VrxzAOlz0rWRUsz82JyAKw+sLp6BrhoW89UI/ncBFOHz4uL8RgYypQu gQw+mQB8JH87o1E8xpRZr/GvO/djtYkyVIghNJ4yMa6kgFBbhVQF6VQuLs17nFoqklPQ xxduMJNeVOplWD7XEXEPNQsCQxa3XA7PjAW8xPZ/4mK0vkYIXAvG+clfZ9Fdy9adlEq+ kCDAdUNWqb/pud5XcHL7Ffhb3AvqvxZuowAobenmlRuoxyT+MrmyRImmt0RHJVEIy3wA 4vtLxPe66XSqpLjcv8qVGBeNGkf6U/6R4hXz43xeJxNq5oQtoIQYbpLc8bjB72bNJqpU xlMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ez7rGy83; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga18si14552397ejc.519.2020.11.17.06.05.27; Tue, 17 Nov 2020 06:05:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ez7rGy83; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729687AbgKQOCY (ORCPT + 99 others); Tue, 17 Nov 2020 09:02:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:44122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729677AbgKQNNa (ORCPT ); Tue, 17 Nov 2020 08:13:30 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E8B0A24199; Tue, 17 Nov 2020 13:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618809; bh=6keFGEb4fZeEhr7J7Zvd160V9M3jsSUlcfwidtCQGuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ez7rGy833HIbs/ozizNc/i0C4FzDEEUO6XQPsDPidn9isx6r4KjraGSPaMFKLVDvp C5okS5m7+R1z8w8h2ZHXhIoM8oeHTxqY60yAVARY4QCDE/TED2/w2U+r8NB2o32Ssv 5KQ+nd/3MnVpaGnZUq/51proWqf2Ba4JQ+1AdBdM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Mailhol , Oliver Hartkopp , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 4.14 15/85] can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames Date: Tue, 17 Nov 2020 14:04:44 +0100 Message-Id: <20201117122111.784685446@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver Hartkopp [ 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 Signed-off-by: Oliver Hartkopp 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 Signed-off-by: Sasha Levin --- drivers/net/can/dev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 926d663eed37a..e79965a390aab 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -492,9 +492,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; -- 2.27.0