All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
To: Heiner Kallweit <hkallweit1@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Simon Horman <horms@kernel.org>, Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>
Cc: Jacky Chou <jacky_chou@aspeedtech.com>,
	Jacob Keller <jacob.e.keller@intel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net] net: ftgmac100: fix potential NULL pointer access in ftgmac100_phy_disconnect
Date: Thu, 31 Jul 2025 10:58:47 +0200	[thread overview]
Message-ID: <ddbfdf8c-53ab-4993-a53a-60c45d36cae9@linux.intel.com> (raw)
In-Reply-To: <2b80a77a-06db-4dd7-85dc-3a8e0de55a1d@gmail.com>

On 2025-07-30 10:23 PM, Heiner Kallweit wrote:
> After the call to phy_disconnect() netdev->phydev is reset to NULL.

phy_disconnect() in its flow does not set phydev to NULL, if anywhere it 
happens in of_phy_deregister_fixed_link(), which already calls 
fixed_phy_unregister() before setting phydev to NULL

 From my understanding (which very much could be wrong) of 
ftgmac100_probe(), these two cases are mutually exclusive. The device 
either uses NCSI or will use a phy based on the DT "fixed-link" property
> So fixed_phy_unregister() would be called with a NULL pointer as argument.

Given my analysis above, I don't think this case is possible.

Best regards,
Dawid
> Therefore cache the phy_device before this call.
> 
> Fixes: e24a6c874601 ("net: ftgmac100: Get link speed and duplex for NC-SI")
> Cc: stable@vger.kernel.org
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>   drivers/net/ethernet/faraday/ftgmac100.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 5d0c09068..a863f7841 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -1750,16 +1750,17 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
>   static void ftgmac100_phy_disconnect(struct net_device *netdev)
>   {
>   	struct ftgmac100 *priv = netdev_priv(netdev);
> +	struct phy_device *phydev = netdev->phydev;
>   
> -	if (!netdev->phydev)
> +	if (!phydev)
>   		return;
>   
> -	phy_disconnect(netdev->phydev);
> +	phy_disconnect(phydev);
>   	if (of_phy_is_fixed_link(priv->dev->of_node))
>   		of_phy_deregister_fixed_link(priv->dev->of_node);
>   
>   	if (priv->use_ncsi)
> -		fixed_phy_unregister(netdev->phydev);
> +		fixed_phy_unregister(phydev);
>   }
>   
>   static void ftgmac100_destroy_mdio(struct net_device *netdev)


  reply	other threads:[~2025-07-31  8:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30 20:23 [PATCH net] net: ftgmac100: fix potential NULL pointer access in ftgmac100_phy_disconnect Heiner Kallweit
2025-07-31  8:58 ` Dawid Osuchowski [this message]
2025-07-31 19:22   ` Heiner Kallweit
2025-08-01  6:19     ` Dawid Osuchowski
2025-08-05 23:20 ` patchwork-bot+netdevbpf

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=ddbfdf8c-53ab-4993-a53a-60c45d36cae9@linux.intel.com \
    --to=dawid.osuchowski@linux.intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jacky_chou@aspeedtech.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.