Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3872447pxb; Tue, 17 Nov 2020 05:55:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzotbHWTKfNHEW+zk3srHGVUtCxsWNOZKQpnY5fEKmfv060djwWUz0/cKW4+JHrfy+or/tM X-Received: by 2002:a50:9518:: with SMTP id u24mr21332122eda.124.1605621312431; Tue, 17 Nov 2020 05:55:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621312; cv=none; d=google.com; s=arc-20160816; b=aMS2mZNSuIC5ozrdeD36CbZwLZerjBOQ17NTNXUW8NUMTgyHHQTVOKbE1QtOmiJ5tr vKeWsa22h0uTnFiQQqjN4NBx5LAJG6kMLTlnueY5VSMMdHjMTxCoDVKeGmKKN350VTw2 ruqIpl2o3Z9+a4Ba7uXnz3fiyZwUUBrxMO0SoImckcx41XJpk5dMWsIngFcI3B3nuP6R JJeWNSRxfLJyF6T8flVT+BlofIvd1ZxJiaxpieaHhQbX2ridoy1dFgxAybdoCF+i4ebZ dB+b/zUyWya2zHyV6vNh5ZYrRgzbY7xeoyknaBraB6Cfe7SSPcJ1iUfiyPd6MMoDKOo5 g+OQ== 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=9HYHZWkM1MDX77qy3RovCOgpkIoMfcTJzsbtVKEZlJI=; b=Sa20ohy2E3C9etXfc+7QL/KKf1E730jACKgav9iSg/o5upZpMXDR6DBQoM9zNUZSLz 0iNhH/qgxNn+Uiv7xJsJpXGXTgOWBmxWGG5zqzaUP3rkuJZiQlF9WNuWSyglo8tUucIf Vnssje4qMw5OkwXoNo7X2k/7R4w/s//lEKNMYXnU1wZf19ew5h55OZNV0AMJmcGrl3gI DBHFdeib4FHa41QW32k7P6LOdG7UlxEfo98RiMHzhhhcFgJy7fSVp8bwHUj7l1esezOR 5n3MywLNsRYsv9vRd8YPrHELFMWX2e0a4najjFgdb+BTnwaAkliDTAd0CNSdMpmebjBJ vPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gRI1ZdQt; 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 u11si1610912edj.59.2020.11.17.05.54.48; Tue, 17 Nov 2020 05:55:12 -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=gRI1ZdQt; 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 S1733285AbgKQNuy (ORCPT + 99 others); Tue, 17 Nov 2020 08:50:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:41320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731050AbgKQNb5 (ORCPT ); Tue, 17 Nov 2020 08:31:57 -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 00CB02078E; Tue, 17 Nov 2020 13:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619917; bh=2bia6SePkmrj/nEMIR7fnWPfuhgi+aAZoeQkqlJXWiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gRI1ZdQtP9jBCzdkNXqxmLEJwGPbXV40OOKKP3KcxRfRiERKRGPQtVLdLPI47w+sg ZjFqc2TAbuOWEE2wmjAP02LpGNKy7xig7Bw97c+eIzmwXe/NQ56cWT0A9KPzJ745Op EgjBBRtdzIcVWqi25meuyal/AlIfLe7jeeKWN5OQ= 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 5.9 047/255] can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames Date: Tue, 17 Nov 2020 14:03:07 +0100 Message-Id: <20201117122141.241165980@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@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 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; -- 2.27.0