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
Subject: Re: [PATCH net-next v3] tg3: Avoid writing uninitialized MII_CTRL1000 in tg3_phy_reset_5703_4_5()
Date: Sun, 29 Nov 2026 00:55:36 +0000 [thread overview]
Message-ID: <179591373694.3135.13755573347057829013@kernel.org> (raw)
In-Reply-To: <20261125004231.1007868-1-irogers@google.com>
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
prev parent reply other threads:[~2026-11-29 0:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 0:42 [PATCH net-next v3] tg3: Avoid writing uninitialized MII_CTRL1000 in tg3_phy_reset_5703_4_5() Ian Rogers
2026-11-29 0:55 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179591373694.3135.13755573347057829013@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elkin@google.com \
--cc=irogers@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox