From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795913738; b=K/5b6OoiyVLZPvq3gkd0h9GOSHUGoAWOn9Pdj1pxPsasUbxUmUZHKWjP5BBYqI/H0ftb aIS54i0rt2CKP0C86e8T+ML1w9/dZxKC0/xljtuHAdjMD2IgPFwTHOs/1ogSnEajbQ5LI mU2TJY+/HXbcWje34YvqsGEc6mup3lV00ZzzU5h2dULWtssnJk1CrkQA0TGkyBJ49fngS wkpur3ru4tX6pGxWe/b4AiE3bEJ3DF4UYy3D/em1ktpRThwxquqzmv7uPLw0gssqqeoWv g2z3BtA51q2DgoXRwCMe7PE0q/VGcwBrhyOAphrn6FHxITwDnF/nR4QQTEvGtMnN7yQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795913738; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=BHHHL6fvQ9YVlyMg5vjWWuVfocn6B3SBEqZ3a026HH4=; b=XXlWIoUdFIaKCMFS3aadInYWsQY2V9V7kYyxehxaUCAPfFukDbj10zHtyQGtsXih8FNT YD2fJna1iwzPVaImzMlHie/xXz4YhNHqCMP7XPIkko+1dUzXi6Ff+AA2tHg0jAUx3KdNa GIY86UoylQ2kt9D0q+ETcT4LMRA/CGvIM9mcZXIoEEddLiG4rWUgbM7YqgyqlIc+pcuWw v7bwbvLw1Mg7eoaLMGuwzNCOT3Qwz9vpzaUJeN6tzYLNR2uLptRWGt3bE41jKfbWRBT3Z nIMaVHBU8ELMtdOhym2bVBy+kUSnkpmGBnjUo9/GcaKklJwJQIq0kcVWKxn8H1VBCHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fRf01XEp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63E8B606A323; Sun, 29 Nov 2026 00:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fRf01XEp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 632A61F000C1; Sun, 29 Nov 2026 00:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795913738; bh=BHHHL6fvQ9YVlyMg5vjWWuVfocn6B3SBEqZ3a026HH4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=fRf01XEpNRhgx3r/NqRYabZAz+oUJXJJRBGw4x6z6unwVIEhdq1EV15NHZnOpwtmG eqeC48vor4i7y4ahybWH87A6PZRLWWadqJCCG2PXrUkBt4QRpppos+LfXe+JkULFPd kT8oWBedtCB+jpcN6RMwt3XfuU/FZDuH5g0h6kUWhSyHsKySCugwERQyh+sLo5L+9a b9buo8k49VwRSyVQ3wj4bs2OBxjGbXOGE2NAnJ57eJLgGneA2GQ9bfXKEuNhUCUxv5 5+5QS+mKPDoHy/ZkTlvpQ1p0yUPScJLeYVWGvsE3JQyqhw+x3ncN9G6FPgckYO5vzl wK4z3UY03ASoQ== Subject: Re: [PATCH net-next v3] tg3: Avoid writing uninitialized MII_CTRL1000 in tg3_phy_reset_5703_4_5() From: netdev-bot+sashiko@kernel.org To: irogers@google.com Cc: pavan.chebbi@broadcom.com, michael.chan@broadcom.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, elkin@google.com Date: Sun, 29 Nov 2026 00:55:36 +0000 Message-ID: <179591373694.3135.13755573347057829013@kernel.org> In-Reply-To: <20261125004231.1007868-1-irogers@google.com> References: <20261125004231.1007868-1-irogers@google.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] In tg3_phy_reset_5703_4_5() (drivers/net/ethernet/broadcom/tg3.c), the new phy9_orig_set flag is… -- tg3: Avoid writing uninitialized MII_CTRL1000 in tg3_phy_reset_5703_4_5() This patch adds a phy9_orig_set flag to tg3_phy_reset_5703_4_5(). The flag records that MII_CTRL1000 was read, and the post-loop restore of MII_CTRL1000 now only happens when the flag is set. It also zero-initializes phy9_orig to quiet Clang's -Wconditional-uninitialized warning. > diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c > index 95827df4cf6a1..21d21fb2b0161 100644 > --- a/drivers/net/ethernet/broadcom/tg3.c > +++ b/drivers/net/ethernet/broadcom/tg3.c [ ... ] > @@ -2571,6 +2572,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp) > /* Set to master mode. */ > if (tg3_readphy(tp, MII_CTRL1000, &phy9_orig)) > continue; > + phy9_orig_set = true; > > tg3_writephy(tp, MII_CTRL1000, > CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER); > @@ -2598,7 +2600,8 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp) > > tg3_phy_toggle_auxctl_smdsp(tp, false); > > - tg3_writephy(tp, MII_CTRL1000, phy9_orig); > + if (phy9_orig_set) > + tg3_writephy(tp, MII_CTRL1000, phy9_orig); [Severity: Medium] Can this still write 0 to MII_CTRL1000 when phy9_orig_set is true? Once phy9_orig_set is set it stays set. But every pass of the retry loop reads MII_CTRL1000 straight into phy9_orig. __tg3_readphy() clears the output before the MDIO transaction and only fills it in on success: drivers/net/ethernet/broadcom/tg3.c:__tg3_readphy() { ... *val = 0x0; ... ret = -EBUSY; if (loops != 0) { *val = frame_val & MI_COM_DATA_MASK; ret = 0; } ... } So consider this sequence: iteration N: tg3_readphy(MII_CTRL1000) succeeds, phy9_orig_set = true tg3_phy_write_and_check_testpat() fails, loop retries iteration N+k: tg3_readphy(MII_TG3_EXT_CTRL) succeeds tg3_readphy(MII_CTRL1000) times out, phy9_orig = 0 continue (phy9_orig_set is still true) no later iteration succeeds Here the guarded restore writes 0 to MII_CTRL1000. That clears the 1000BASE-T advertisement and the master/slave settings. The commit message says: Track whether MII_CTRL1000 was successfully read with a phy9_orig_set flag and only restore MII_CTRL1000 when phy9_orig_set is true In this case, though, the value being restored comes from a read that failed. Would it work to read into a temporary and latch phy9_orig only on the first successful read? For example: if (tg3_readphy(tp, MII_CTRL1000, &tmp)) continue; if (!phy9_orig_set) { phy9_orig = tmp; phy9_orig_set = true; } That would also stop later iterations from replacing the saved value with the CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER value the loop itself wrote on an earlier pass. > > err = tg3_readphy(tp, MII_TG3_EXT_CTRL, ®32); > if (err) -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125004231.1007868-1-irogers%40google.com