mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonas Gorski <jonas.gorski@gmail.com>
To: Alexey Simakov <bigalex934@gmail.com>,
	Michael Chan <michael.chan@broadcom.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Michael Buesch <mb@bu3sch.de>,
	"John W. Linville" <linville@tuxdriver.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH net] broadcom: b44: prevent uninitialized value usage
Date: Thu, 4 Dec 2025 14:39:48 +0100	[thread overview]
Message-ID: <a5236fe2-4e9b-49ef-9734-f3b60746896d@gmail.com> (raw)
In-Reply-To: <20251204052243.5824-1-bigalex934@gmail.com>

Hi,

On 12/4/25 06:22, Alexey Simakov wrote:
> On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy()
> leaves bmcr value uninitialized and it is used later in the code.
> 
> Add check of this flag at the beginning of the b44_nway_reset() and
> exit early of the function if an external PHY is used, that would
> also correspond to other b44_readphy() call sites.
> 
> Found by Linux Verification Center (linuxtesting.org) with Svace.
> 
> Fixes: 753f492093da ("[B44]: port to native ssb support")
> Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
> ---
>  drivers/net/ethernet/broadcom/b44.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
> index 0353359c3fe9..cbfd65881326 100644
> --- a/drivers/net/ethernet/broadcom/b44.c
> +++ b/drivers/net/ethernet/broadcom/b44.c
> @@ -1789,6 +1789,9 @@ static int b44_nway_reset(struct net_device *dev)
>  	u32 bmcr;
>  	int r;
>  
> +	if (bp->flags & B44_FLAG_EXTERNAL_PHY)
> +		return 0;

Wouldn't the right fix here to call phy_ethtool_nway_reset(dev->phydev); instead
of just returning 0? That way it properly restarts auto-negotiation even in this
case.

> +
>  	spin_lock_irq(&bp->lock);
>  	b44_readphy(bp, MII_BMCR, &bmcr);
>  	b44_readphy(bp, MII_BMCR, &bmcr);

Best regards,
Jonas

  parent reply	other threads:[~2025-12-04 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-04  5:22 Alexey Simakov
2025-12-04 13:34 ` Andrew Lunn
2025-12-04 13:39 ` Jonas Gorski [this message]
2025-12-04 13:42   ` Andrew Lunn

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=a5236fe2-4e9b-49ef-9734-f3b60746896d@gmail.com \
    --to=jonas.gorski@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigalex934@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=lvc-project@linuxtesting.org \
    --cc=mb@bu3sch.de \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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®