Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2618885rda; Wed, 25 Oct 2023 07:51:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERlaBoAhL1QUFgjF/4U8R5OvAUhKwEli0t/uxt8vq2x7niYUAwc4Zf7KNej1j+PYuAJyDv X-Received: by 2002:a0d:d6d7:0:b0:5a7:bb95:681c with SMTP id y206-20020a0dd6d7000000b005a7bb95681cmr19512796ywd.36.1698245499702; Wed, 25 Oct 2023 07:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698245499; cv=none; d=google.com; s=arc-20160816; b=K+L7LQ1/XGLymPVJRoQw//exd5vw5kVptvqsY35oliZsqjf+jVHVRIxKEc/xJ35hDB 1bqDSq4pKfPsO1PhkClmr5ljpfUhfNIvxxJ+6nlthREY225mf2HAFthl/OYNbtPglzyt 8gZMdUqAKEsZvGQ75EC8yQZq5mQR6SrOqUKroQGltkGbPafiqk5MjW87KH08VvoyvVnG zTh1R2KAP3XFgtXw0p75b/j8oF0voPF9EzOd8Oz9JI8cvhP5GGFlyuVC3qANIEwJML/z ZeZZ+JHoJs6ikyBkTpd39oG4fLvB3rn6I+Urd1I9L0snUIo0sKvkrKjn5tYwGBnWNCs3 Z4qA== 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=eVkn97O4NIJxFrhso3xYP9hpKXHqOLBP+WT1zXqgJTA=; fh=8PAY1Ks1uaZoe4Ekdw6GpGKm51YqFyueA94ZCJrJ86E=; b=M4+RJ7gSPo2BOsB45VTmAPd9cQ1fwmz6c0gtTHOLYdhfeo2QaYMUSD8eTa9ergSREi 0Va6QogmHGXRX7DalCie7JLtVk3BNWA4k7iOFD9bnsCga8Q0WOutto+heCAEQQFww/Ki K5HMfT7EYXflZCR9BL7YHoLIYlb9kCQDD+4pN9kx2BXOyuDs3jk52HYnV0/InyinRVBH /7JV8JuEul5jlBKpHVi0d4JeNzEAx3Id8II1mAd3Pn6KbCz8r4Y+YM+BspfxudRgk+vi ff14o8rgdZUmXWy5vPrpTZ5/vxLMwNYog9u1kbFfmuvxto2+N6RL4eNp1WqPaXQk8zUs 3IWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ma6rDtha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m85-20020a0dca58000000b0059f5772c1f3si10173213ywd.129.2023.10.25.07.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 07:51:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ma6rDtha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7A66981C0CAE; Wed, 25 Oct 2023 07:51:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344254AbjJYOvP (ORCPT + 99 others); Wed, 25 Oct 2023 10:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344176AbjJYOvN (ORCPT ); Wed, 25 Oct 2023 10:51:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C920136; Wed, 25 Oct 2023 07:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698245471; x=1729781471; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=l/NJMRjSMo3od/OVoprgvRt/zRss9xwyAblrboJ/CAc=; b=Ma6rDtha9Tp0RxAmrqD+n+Vp3tkBTBl2VSoLKahHS2cv7aegIPc6uQuG QbNkcwndjOHWK/atibXlW/Kx5XoQUnZz1cHLFd1nwFpVmhlAFCiQwSpWw K8JejvOCdkNtaHeGWxdl81/blVZqL4nZ/dfWUauTVgcDrpqNVQesD+c5r B+KqSXEp8gQbc/uHTzMefFbPbJnkrWvbuRJ9bz2gc6dIltRU0xm8wPdvT aDlUyws6KZhn2IwXeH29n15E8RrxxdY53OlshVocTN1lb6w9t8cIQwn9D VhEuL2gr4Daqn8kNg4uMbdbcp21WTJC03jPim1OkxUyz4kmx2MI/Z3dt6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="453789860" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="453789860" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 07:51:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="1090250352" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="1090250352" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga005.fm.intel.com with ESMTP; 25 Oct 2023 07:51:06 -0700 Received: from pkitszel-desk.intel.com (unknown [10.255.194.221]) by irvmail002.ir.intel.com (Postfix) with ESMTP id EF9CD381BD; Wed, 25 Oct 2023 15:51:01 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org, Saeed Mahameed , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko Cc: linux-kernel@vger.kernel.org, Leon Romanovsky , Tariq Toukan , Danielle Ratson , Ido Schimmel , Petr Machata , Moshe Shemesh , Eran Ben Elisha , Aya Levin , Simon Horman , Przemek Kitszel , Dan Carpenter Subject: [PATCH net-next] net/mlx5: fix uninit value use Date: Wed, 25 Oct 2023 16:50:50 +0200 Message-Id: <20231025145050.36114-1-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 07:51:31 -0700 (PDT) Avoid use of uninitialized state variable. In case of mlx5e_tx_reporter_build_diagnose_output_sq_common() it's better to still collect other data than bail out entirely. Reported-by: Dan Carpenter Link: https://lore.kernel.org/netdev/8bd30131-c9f2-4075-a575-7fa2793a1760@moroto.mountain Fixes: d17f98bf7cc9 ("net/mlx5: devlink health: use retained error fmsg API") Signed-off-by: Przemek Kitszel --- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c | 6 +++++- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c index fc5a9fdd06db..fea8c0a5fe89 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c @@ -263,8 +263,12 @@ mlx5e_rx_reporter_build_diagnose_output_rq_common(struct mlx5e_rq *rq, if (rq->icosq) { struct mlx5e_icosq *icosq = rq->icosq; u8 icosq_hw_state; + int err; + + err = mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state); + if (err) + return err; - mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state); mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c index ccff7c26d6ac..6b44ddce14e9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c @@ -221,12 +221,16 @@ mlx5e_tx_reporter_build_diagnose_output_sq_common(struct devlink_fmsg *fmsg, bool stopped = netif_xmit_stopped(sq->txq); struct mlx5e_priv *priv = sq->priv; u8 state; + int err; - mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state); devlink_fmsg_u32_pair_put(fmsg, "tc", tc); devlink_fmsg_u32_pair_put(fmsg, "txq ix", sq->txq_ix); devlink_fmsg_u32_pair_put(fmsg, "sqn", sq->sqn); - devlink_fmsg_u8_pair_put(fmsg, "HW state", state); + + err = mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state); + if (!err) + devlink_fmsg_u8_pair_put(fmsg, "HW state", state); + devlink_fmsg_bool_pair_put(fmsg, "stopped", stopped); devlink_fmsg_u32_pair_put(fmsg, "cc", sq->cc); devlink_fmsg_u32_pair_put(fmsg, "pc", sq->pc); -- 2.38.1