Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3876832pxb; Tue, 17 Nov 2020 06:01:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHDm7UH7dNKpJp5hi5sJlBClCmVGTu7m6QkYgxtWpp3QyrgkWj+81mZl55PsmiDlfbdSCa X-Received: by 2002:a17:907:2166:: with SMTP id rl6mr19638807ejb.61.1605621716709; Tue, 17 Nov 2020 06:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621716; cv=none; d=google.com; s=arc-20160816; b=hjU4A6DxRLfomKf2wCCG3RUcml6nCIoNgioP9Q37cpi9IUYzsSKn8Fqx7NMyabER5t /j+ulu42shQs2XltE455Na7YrpTEcbO3FlIA+53QDzex+xNM2lxEJ7L+CWMAlr6JykyZ 9vgeqMbu0ZsNu9hOKiQdt2/kCieVdhAY1mKiHzME/9TuXYkYG0sc6ckHuMFiht0HIJy3 /S5FysWk/k0nyYzrC+gA0dZNC15ffTtnG4ndLWLUZts56Lpy4IIqEn2jdKnt6lJbE13n +ptsfhzNCFuEDWa4mlnMLpz087Li9Nv112EfUWTFjkDpLlZdR4L2Hz5nfQwSWsOgeLXW HuDg== 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=KokNPTBoqi784aof2NvnSWvL8VEWBB2kQyL5uVXlPHk=; b=qxVHMZ/WJtSx6UV0WQnbtAao9slbPVquWPgwLJVquBgTMP5cesGtXWXwId3OLASH1E cw0z7v4YHZgz0mUhylQa/79MU8FDJT/m47p1OGuQmt2X8IgDXffA03YgUgOhZ9c17iqU x3ANm4OfzzI7TX1w7ZksaOqWbQuagplJo6j421QpHMVGhWZC8tXdLqlrPDMlof4ZIUkv 98BzLR5meQQ5lFmoB0a30+s7ptusLuuqp5ICWd/HrArG2Zt0C1y/tMZFaNebbfjliIzj J4StuRwJNis9iJLUH5RRP8scdjvR/YlpSLIl07urOkqGdVccxM+UF6d0La86Q4044BB2 ioVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FfELSIec; 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 p15si14557028edq.35.2020.11.17.06.01.33; Tue, 17 Nov 2020 06:01:56 -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=FfELSIec; 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 S1730053AbgKQN73 (ORCPT + 99 others); Tue, 17 Nov 2020 08:59:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:50132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730596AbgKQNRr (ORCPT ); Tue, 17 Nov 2020 08:17:47 -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 13DE02463D; Tue, 17 Nov 2020 13:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619066; bh=0iwJuiQzlg0IcIRmnTjdvR37SNEbZGygc+Kl6YTufgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FfELSIec9AR3G9Yw2CSO7F3/GK148jlnE3lj9n0PByJsxwrX96UNAtgSiAFLG7b+d oafsoRl3aUeJkaXVVVIqGkTe/+WE5OAzGTAbMU6ByZNe2CM1IWRWAQjMLcoFxTs2oV wxh8hQIz31wOcGpPhYBJA/Q/vhMD1xWIAi+yiyxE= 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.19 017/101] 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: <20201117122113.934953076@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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 be532eb64baa2..1950b13f22dfc 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -493,9 +493,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