mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Ruoyu Wang <ruoyuw560@gmail.com>
Cc: Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error
Date: Fri, 14 Aug 2026 16:18:04 +0200	[thread overview]
Message-ID: <131ce445-605c-4408-aa25-fcd32f53c301@lunn.ch> (raw)
In-Reply-To: <20260814134006.1386372-1-ruoyuw560@gmail.com>

On Fri, Aug 14, 2026 at 09:40:06PM +0800, Ruoyu Wang wrote:
> An SMI timeout or PPU access failure can make a Clause 22 PHY read
> return without initializing its output value. When reading MII_PHYSID2,
> mv88e6xxx_mdio_read() still passes that value through the internal PHY
> model-number workaround before returning the error, causing an
> uninitialized stack read.
> 
> Run the workaround only after a successful PHY read. This preserves the
> original error and leaves successful PHY ID reads unchanged.
> 
> This issue was found by a static analysis checker and confirmed by
> manual source review.
> 
> Fixes: da9f33018e2c ("net: dsa: mv88e6xxx: Workaround missing PHY ID on mv88e6390")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
>  drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 80b877c74513d..e71707ce71cbc 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -3770,7 +3770,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
>  	mv88e6xxx_reg_unlock(chip);
>  
>  	/* Some internal PHYs don't have a model number. */
> -	if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
> +	if (!err && reg == MII_PHYSID2 && !(val & 0x3f0) &&
>  	    chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
>  		prod_id = family_prod_id_table[chip->info->family];
>  		if (prod_id)

Ugly.

Please do the usual for checking for errors and returning.

Also, this is not worthy of stable, please drop the Fixes tag, and
post to net-next.

       Andrew

      reply	other threads:[~2026-08-14 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 13:40 Ruoyu Wang
2026-08-14 14:18 ` Andrew Lunn [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=131ce445-605c-4408-aa25-fcd32f53c301@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=ruoyuw560@gmail.com \
    --cc=vivien.didelot@gmail.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

all inboxes | Powered by JetHome®