Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp3973276rwn; Sun, 11 Sep 2022 02:16:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/1T8Rmj4hFLfgPz7E2+mi1qVhJi8CqntTfYDZRKpiNPW64JRZ98Jb/BTCKdkYgsMeJy1B X-Received: by 2002:a17:90b:2245:b0:200:57df:44cf with SMTP id hk5-20020a17090b224500b0020057df44cfmr18650064pjb.135.1662887819201; Sun, 11 Sep 2022 02:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662887819; cv=none; d=google.com; s=arc-20160816; b=zTRvopSZw2vU9H/o6utZ2MwP6l9+BQKOgGXSa71mA8JDUpAkLuGi9+Yl383QM3Fn8B 5Ek3Wi4r36MpGrlJ4x7gTNkvYop0NHIOTYB9H+6xLBaaw9IaD8/E0GdUIu4SXcPWFJpV QpEDsvnrKBEVgg10rNT4KOm0njFpwGU+awlt5iyjKKsiazoWddIT3hyALGcbNyy8ZwpK 70UN2hemgImZMovkuYYz8OH7Zcr/jvAhFehgTqVCQF5TFW5ltyi4g60MS8G1lOqNtEqS 382uED/lclK4ObNUcXdXYqQQJHP5uBEYasSXImsR1d6JW7vdGsqZgLPF3KjGcMV6ogrk RDfA== 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:dkim-signature; bh=KDuEfX5YCOOERWnWPWA32tbbwBGHtAbxHss392gbvqo=; b=oX737xyvjUh6nPbO6iUC+izrixliXTnOOxMB16dw1ZfSj6aOq3SL20bF8+S5Ns/wxU FYAIcuLGdLa0v3kWE+pp2zy8IQi7FbDkFHt6jx0YztFWb/kOvIpaIYr7iIYIELg8Mk1S cVgMzGsWKhjufeqx2fiLwVh9MXgtbpSNZIEcgynMlvJIAugCZYpYREQUwFLFmANU92yq S6qRK/9HVCHf/ZohDSwXt8KeGCwk74pV7HoSBDzfkH0+M8jvOOaJ3REWQBVan0/Xx9oY 4pz3NSp9gHNhSpAf//4vGBIsDlFyz6CG+ja/N2ifZoiyBqZkZv4vCLtB8pvEvuqNMrZD uNgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L2jx8OlS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020a63e944000000b0042abd0064d2si5745490pgj.826.2022.09.11.02.16.47; Sun, 11 Sep 2022 02:16:59 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L2jx8OlS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbiIKJDX (ORCPT + 99 others); Sun, 11 Sep 2022 05:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiIKJDT (ORCPT ); Sun, 11 Sep 2022 05:03:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93A8399FB; Sun, 11 Sep 2022 02:03:16 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 5829960F3C; Sun, 11 Sep 2022 09:03:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB60EC433D6; Sun, 11 Sep 2022 09:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662886995; bh=rTvQIbrU8zayFPKG6ZUyF2mG4VPXoXeA1CW6REYuqB4=; h=From:To:Cc:Subject:Date:From; b=L2jx8OlSyrruY2VcSfA4xJt2feLDZovdI2FOUHu56hA6MEO0lEgJy0WCxP78DtwBQ fb3Ci9pX2go/O5TbYJWsoGbHevQKVgqj4/VldC0tN+M9JsQbq/MxJLy8+RPrsPjLpS Em0zC2gNgE5Mrg2CJZrZVQPwngOV0KcL52VpYWrx00tNrHzc9v3Vhs7ir5oh2YpWXP 1Xmw2Fj3Qy942ArwOVlHky8+5/3Ow1TaeNldYQJGPohuzN9jPcHjQykAvmGR90xAUO lNEM0CvEW9mOQrfFsWkVDYTEng8KyqKn0EPPvOiJ96+TxFMkjhDtmwiTH2ctB9DTSD EweLI+q4MtV4w== From: Nathan Chancellor To: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Nick Desaulniers , Tom Rix , Boris Pismenny , Raed Salem , Lior Nahmanson , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor Subject: [PATCH net-next v2] net/mlx5e: Ensure macsec_rule is always initiailized in macsec_fs_{r,t}x_add_rule() Date: Sun, 11 Sep 2022 01:57:50 -0700 Message-Id: <20220911085748.461033-1-nathan@kernel.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 Clang warns: drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:539:6: error: variable 'macsec_rule' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (err) ^~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:598:9: note: uninitialized use occurs here return macsec_rule; ^~~~~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:539:2: note: remove the 'if' if its condition is always false if (err) ^~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:523:38: note: initialize the variable 'macsec_rule' to silence this warning union mlx5e_macsec_rule *macsec_rule; ^ = NULL drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1131:6: error: variable 'macsec_rule' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (err) ^~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1215:9: note: uninitialized use occurs here return macsec_rule; ^~~~~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1131:2: note: remove the 'if' if its condition is always false if (err) ^~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1118:38: note: initialize the variable 'macsec_rule' to silence this warning union mlx5e_macsec_rule *macsec_rule; ^ = NULL 2 errors generated. If macsec_fs_{r,t}x_ft_get() fail, macsec_rule will be uninitialized. Initialize it to NULL at the top of each function so that it cannot be used uninitialized. Fixes: e467b283ffd5 ("net/mlx5e: Add MACsec TX steering rules") Fixes: 3b20949cb21b ("net/mlx5e: Add MACsec RX steering rules") Link: https://github.com/ClangBuiltLinux/linux/issues/1706 Signed-off-by: Nathan Chancellor --- v1 -> v2: https://lore.kernel.org/20220908153207.4048871-1-nathan@kernel.org/ * Don't use a label and goto, just initialize it to NULL at the top of the functions (Raed). Tom, I did not carry forward your reviewed-by tag, even though this is a pretty obvious fix. Blurb from v1: I thought netdev was doing testing with clang so that new warnings do not show up. Did something break or stop working since this is the second time in two weeks that new warnings have appeared in -next? drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c index 608fbbaa5a58..13dc628b988a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c @@ -518,9 +518,9 @@ macsec_fs_tx_add_rule(struct mlx5e_macsec_fs *macsec_fs, struct mlx5_pkt_reformat_params reformat_params = {}; struct mlx5e_macsec_tx *tx_fs = macsec_fs->tx_fs; struct net_device *netdev = macsec_fs->netdev; + union mlx5e_macsec_rule *macsec_rule = NULL; struct mlx5_flow_destination dest = {}; struct mlx5e_macsec_tables *tx_tables; - union mlx5e_macsec_rule *macsec_rule; struct mlx5e_macsec_tx_rule *tx_rule; struct mlx5_flow_act flow_act = {}; struct mlx5_flow_handle *rule; @@ -1112,10 +1112,10 @@ macsec_fs_rx_add_rule(struct mlx5e_macsec_fs *macsec_fs, u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {}; struct mlx5e_macsec_rx *rx_fs = macsec_fs->rx_fs; struct net_device *netdev = macsec_fs->netdev; + union mlx5e_macsec_rule *macsec_rule = NULL; struct mlx5_modify_hdr *modify_hdr = NULL; struct mlx5_flow_destination dest = {}; struct mlx5e_macsec_tables *rx_tables; - union mlx5e_macsec_rule *macsec_rule; struct mlx5e_macsec_rx_rule *rx_rule; struct mlx5_flow_act flow_act = {}; struct mlx5e_flow_table *ft_crypto; base-commit: 169ccf0e40825d9e465863e4707d8e8546d3c3cb -- 2.37.3