Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp22884pxb; Tue, 12 Apr 2022 15:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr63e8KEqNm4KJC/w6nrpGhxYU1iASayESy5zXs5WSrG3x9rkfRwfNIxlPEfhz+tnbpzqG X-Received: by 2002:a17:90b:1e01:b0:1cb:bc00:2828 with SMTP id pg1-20020a17090b1e0100b001cbbc002828mr7297185pjb.91.1649803332291; Tue, 12 Apr 2022 15:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649803332; cv=none; d=google.com; s=arc-20160816; b=gZKHdcE3xL7mxOzUj0svYm/2ER/KGcWpo8Ch81/hw6GM5o9AeHFT7/LxqOLcVfrG1m 3CE9dfvXh6vvThHRRMWBEXNkOkvldimzNj99BsDz1t4jDZ28ijZd5IUUnU3UXIqYthuE 9B0CHj/orK0Vj9g2GN921myHjnQDN3/pzGX/rnriAvIj95x6MM2iMZ5hXaidTgLfqfM2 Osbc5SocksB7vzjz2BrzgV4I/L2yuBohhfbaC9z21AGlSqeC5im3XBCD2OJgxc4y1mWA rqWkNWPnn4WFpRnDT5UTrztzSLZt0SGeiH6dMPSOB5TQTNEblI8OLBHNELSDlUv8ADcv fz2A== 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=/fSEe+98KCklDa7hBA43j2lImp9t+rezOqw/2POrWqU=; b=Ys+zzZYlHsivuz+AS9SLoXUESNTyYBraL57KyVxZJJ4+0Sz3qD3sAggnoghIXgY5tM Z3NmpYAkGZp0CwV9Bh8JvY+GjOCmWIUUndujI3rjuo5G42wJ5BgCM2Y/Dfprk8wf+EcL rxqy/iFcH/SvEsy8168vwJX/W32/6wbCjedAtZZMeCdHrbV6WyrFR22JT7DJmixvarJg gjTcuuDeR41eBmKRjpb8/yi3SwLZ4fCx3Jzz95vKPOzSsySkhb8cDK7IiQ7GnlNMxVpE PsvWj22Ga/i8iWOf+mcV2TP9/QpwEE92rvyQWwFjkSvLRkz4L08qeZs7FI8kNiMe6uS6 lZdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+CQ2RIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id cd25-20020a056a00421900b004fdb5bf7840si2742622pfb.138.2022.04.12.15.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:42:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+CQ2RIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75F04108BE2; Tue, 12 Apr 2022 14:21:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384219AbiDLIjo (ORCPT + 99 others); Tue, 12 Apr 2022 04:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357162AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E2B413DFE; Tue, 12 Apr 2022 00:13:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DDB15B81B40; Tue, 12 Apr 2022 07:13:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 572AEC385A5; Tue, 12 Apr 2022 07:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747589; bh=vakCdvee7SIQCIJsOXH5YHwEpOpJbOq2zIJG+tti2LY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+CQ2RIpDusNfXgy96Se7ZaJE6LPDYglO+4hstB4DqYuR/+Xc2fSQdBi38Tlnh2Zk caaeRdQ3/LJOV+NRxkQ+VQIPI50I2sWo6p+sC/muxtZGYqPQHKU1DY6sbJtU2JnRhI wZThjnV0SpLY/FJuEFbiZ/8QO+Ehm08K3CZwBdx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Mailhol , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.17 134/343] can: etas_es58x: es58x_fd_rx_event_msg(): initialize rx_event_msg before calling es58x_check_msg_len() Date: Tue, 12 Apr 2022 08:29:12 +0200 Message-Id: <20220412062955.251503928@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Vincent Mailhol [ Upstream commit 7a8cd7c0ee823a1cc893ab3feaa23e4b602bfb9a ] 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 dereferences an uninitialized variable: *rx_event_msg. This is actually harmless because es58x_check_msg_len() only uses preprocessor macros (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/v5.16/source/drivers/net/can/usb/etas_es58x/es58x_core.h#L467 Link: https://lore.kernel.org/all/20220306101302.708783-1-mailhol.vincent@wanadoo.fr Signed-off-by: Vincent Mailhol Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- 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 ec87126e1a7d..8ccda748fd08 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_fd.c +++ b/drivers/net/can/usb/etas_es58x/es58x_fd.c @@ -172,12 +172,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.35.1