Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2700013pxx; Sun, 1 Nov 2020 07:02:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTn9aVy9pCLB3miiB2ts9CXUj2pKza9+HDtRwkVF6BhPFbZ/YjkopbJpzRkIJdaZuFZ0CL X-Received: by 2002:a17:907:20d6:: with SMTP id qq22mr10991524ejb.187.1604242924268; Sun, 01 Nov 2020 07:02:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604242924; cv=none; d=google.com; s=arc-20160816; b=WV5WbsVyvmB+DIwgjEvqFBYjNz+LaWpZAhzqjbCUdx9rV0i1C6hQpAcop/SzdGP3Tn 3C0wucrQ1sOmwAdolGmwYzcd2SE065vmC9keGeXFP3Qr7MiEdIto0/D3ZW6zWOCUYZ52 1M/RJLDr1aFJ21HNZTC5H/5hzHpNpLtnwo+xO7yVN0T9dZEMXYCl2whZ1Fwxh164irL1 bUMEPnyHOL6otNsnnLoyfEgK4ovFE2V3Gz2TRcZ2XCxK/X8/il/SstCifomHvo9LAo8i q2pEi0hPxhSeyy7a/dYn2weRRzybCF176/k2K05DVrwhtUDHcM2AoCqSlMxK128vAe7T uEPw== 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 :message-id:date:subject:cc:to:from; bh=0OLuREs0m1JXM6C/R+aKLe2ZQkQJXkFHwggGFt8vEA8=; b=meEMaMthF1JGunf53/VGzuW0/+mVbhq+G/MqQ1ppjLlm27ZXxqO0m4KF+yJ853u4tR aFTGRAiPLubpL9Ay+PJFgNuQDVCUCYu23JM5wC2223yQ0iNQQopN62+m4JCFY4PPPpoN HVWYlrhIio5Nc/pFhuNtky+cxvcmdNhEMRhKngXGGn3cVxhykSAXKS8zAMol/SN6dHeW Sd6P1K45/7rcbG36xjI/nekkCGHezEckXYQwsRCT1ncnf0B40UYsfKiYvoRpnGLuUBpV fvUUNnSha9xqhNlgv8NrOM7kqBPKvHY7i8OAUmm+IUPBEnELE73XBZumO4sIX0ByWbmf GMxA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si9421227edl.592.2020.11.01.07.01.38; Sun, 01 Nov 2020 07:02:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbgKAO5n (ORCPT + 99 others); Sun, 1 Nov 2020 09:57:43 -0500 Received: from smtp03.smtpout.orange.fr ([80.12.242.125]:44004 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726458AbgKAO5n (ORCPT ); Sun, 1 Nov 2020 09:57:43 -0500 Received: from tomoyo.flets-east.jp ([153.230.197.127]) by mwinf5d06 with ME id n2xU230022lQRaH032xfSm; Sun, 01 Nov 2020 15:57:41 +0100 X-ME-Helo: tomoyo.flets-east.jp X-ME-Auth: bWFpbGhvbC52aW5jZW50QHdhbmFkb28uZnI= X-ME-Date: Sun, 01 Nov 2020 15:57:41 +0100 X-ME-IP: 153.230.197.127 From: Vincent Mailhol To: linux-kernel@vger.kernel.org, Oliver Hartkopp Cc: Marc Kleine-Budde , Vincent Mailhol Subject: [PATCH] cangen: flush the CAN frame at each iteration Date: Sun, 1 Nov 2020 23:57:12 +0900 Message-Id: <20201101145712.489795-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The variable 'frame' is declared on the stack and is reused at each iteration of the while loop. If not flushed, garbage data from the previous iteration of the loop could remain causing unexpected behavior. This is the case in DLC random mode: the field frame.len8_dlc is not cleared when the dlc is exactly 8 and the len8_dlc value of the previous iteration will be sent again. This can be observed by running 'cangen -8 can0'. Once a frame of DLC in the range 9..15 is generated, no more frames of DLC 8 show out in the log. Signed-off-by: Vincent Mailhol --- cangen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cangen.c b/cangen.c index ab8122c..d7392b6 100644 --- a/cangen.c +++ b/cangen.c @@ -384,7 +384,7 @@ int main(int argc, char **argv) } while (running) { - frame.flags = 0; + memset(&frame, 0, sizeof(frame)); if (count && (--count == 0)) running = 0; -- 2.26.2