Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1214025pxp; Sun, 6 Mar 2022 08:42:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOVNYDO23hrfmeTbdaRX3WotGGlA79ADFm1klFUYvNxhDiF982e/uJq6UuM55NohVVL2vv X-Received: by 2002:a05:6402:254e:b0:416:4486:ac28 with SMTP id l14-20020a056402254e00b004164486ac28mr1850933edb.110.1646584973017; Sun, 06 Mar 2022 08:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646584973; cv=none; d=google.com; s=arc-20160816; b=iic/vLdj7k7DZvaksKs5xQLraxQppK3ANWUIhmDr06fvwlcMpqL3YqGvLIBcLh6DGN r8eiCAAiDdjO1tilPlFJt19ZJnxr0Nw/3ARN/jYuzBi5SX0ae80fJH+u79UuiWBXxP0U xYvuly3JAbJszSDiZfSKbVmGNkkUyqN0tpSkiHY47OvyRCnTF8CWH/BlK5FBJb7Dsw6r fOVs3PKL2ly6ezLLrku0foh3VEEBshBTLbHhecYUrFYimgjoyI4w5JiwF76hPcp4iuAO K4UbBvnY7JfL4LxtavGCUb7hRZVQynRkPZtqtkbwIl4FtvOwHQ8qeTYNg/d/dxnz7wtp QjRA== 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=u6TicHw2iHFjU4Ks3TivWg0SXFxsyqNOhSghW1ZqErs=; b=hAvUBxrtzz1SRFUA26Cdi9CIc2ooOQ2gPXWG243GlkB21QJmf+KTmNnt6tNRCIJ9oJ NGS8CfwEqAHrxvWxluonuhAyqsk6UIkHC8KjYijygGIhRTpWQyXG4xGEwk1AX9PW4sw6 +z8zWsy7ED5p3uS65s4lHt9q43r9Pbol09IIIETEernxCzFovKW7ky6AgtdI4qkiXHGP 8J1XNYxLHjG90VHnXNBQpDPoqXEiT108yUI5vs7DPVW+TR01wOwmE7/UP1kCN5KNmS09 9BgnaNrYT4MS4lK6a+BTpYQXgNfTa0tXdEMbkeQ9ax9v2UzbJ6FqHiLWENkPVzMmagTo Baug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a05640242d500b00410a9a6f3c8si9406394edc.114.2022.03.06.08.42.28; Sun, 06 Mar 2022 08:42:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233128AbiCFKOR (ORCPT + 99 others); Sun, 6 Mar 2022 05:14:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbiCFKOP (ORCPT ); Sun, 6 Mar 2022 05:14:15 -0500 Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB1D4198D for ; Sun, 6 Mar 2022 02:13:22 -0800 (PST) Received: from localhost.localdomain ([106.133.32.90]) by smtp.orange.fr with ESMTPA id Qnsun8hn1tSo5Qnt6nrJUj; Sun, 06 Mar 2022 11:13:20 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: MDU0YmViZGZmMDIzYiBlMiM2NTczNTRjNWZkZTMwOGRiOGQ4ODf3NWI1ZTMyMzdiODlhOQ== X-ME-Date: Sun, 06 Mar 2022 11:13:20 +0100 X-ME-IP: 106.133.32.90 From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Vincent Mailhol , kernel test robot Subject: [PATCH] can: etas_es58x: initialize rx_event_msg before calling es58x_check_msg_len() Date: Sun, 6 Mar 2022 19:13:02 +0900 Message-Id: <20220306101302.708783-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function es58x_fd_rx_event() invokes the es58x_check_msg_len() macro: | ret = es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len); While doing so, it deferences an uninitialized variable: *rx_event_msg. This is actually harmless because es58x_check_msg_len() only uses preprocessors macro (sizeof() and __stringify()) on *rx_event_msg. c.f. [1]. Nonetheless, this pattern is confusing so the lines are reordered to make sure that rx_event_msg is correctly initialized. This patch also fixes a false positive warning reported by cppcheck: | cppcheck possible warnings: (new ones prefixed by >>, may not be real problems) | | In file included from drivers/net/can/usb/etas_es58x/es58x_fd.c: | >> drivers/net/can/usb/etas_es58x/es58x_fd.c:174:8: warning: Uninitialized variable: rx_event_msg [uninitvar] | ret = es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len); | ^ [1] https://elixir.bootlin.com/linux/latest/source/drivers/net/can/usb/etas_es58x/es58x_core.h#L467 Reported-by: kernel test robot Signed-off-by: Vincent Mailhol --- As discussed in https://lore.kernel.org/linux-can/20220302130423.ddd2ulldffpo5lb2@pengutronix.de/T/#u, no need to backport this patch because this is not a fix. @Yujie Liu: I added the "Reported-by: kernel test robot". This being a false positive, let me know if you would like to remove the tag in order not to mess with you statistics. --- drivers/net/can/usb/etas_es58x/es58x_fd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/can/usb/etas_es58x/es58x_fd.c b/drivers/net/can/usb/etas_es58x/es58x_fd.c index 88d2540abbbe..c97ffa71fd75 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_fd.c +++ b/drivers/net/can/usb/etas_es58x/es58x_fd.c @@ -173,12 +173,11 @@ static int es58x_fd_rx_event_msg(struct net_device *netdev, const struct es58x_fd_rx_event_msg *rx_event_msg; int ret; + rx_event_msg = &es58x_fd_urb_cmd->rx_event_msg; ret = es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len); if (ret) return ret; - rx_event_msg = &es58x_fd_urb_cmd->rx_event_msg; - return es58x_rx_err_msg(netdev, rx_event_msg->error_code, rx_event_msg->event_code, get_unaligned_le64(&rx_event_msg->timestamp)); -- 2.34.1