public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: rmk+kernel@armlinux.org.uk
Cc: Jakub Kicinski <kuba@kernel.org>,
	andrew+netdev@lunn.ch, alexandre.torgue@foss.st.com,
	hkallweit1@gmail.com, vkoul@kernel.org,
	mohd.anwar@oss.qualcomm.com, konrad.dybcio@oss.qualcomm.com,
	andrew@lunn.ch, edumazet@google.com, netdev@vger.kernel.org,
	linux-phy@lists.infradead.org, davem@davemloft.net,
	linux-arm-msm@vger.kernel.org, neil.armstrong@linaro.org,
	linux-arm-kernel@lists.infradead.org, pabeni@redhat.com,
	mcoquelin.stm32@gmail.com,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [net-next,05/14] net: stmmac: add stmmac core serdes support
Date: Thu, 15 Jan 2026 18:57:24 -0800	[thread overview]
Message-ID: <20260116025723.354031-2-kuba@kernel.org> (raw)
In-Reply-To: <E1vg4w2-00000003SG5-2FH5@rmk-PC.armlinux.org.uk>

I haven't investigated too closely if this is legit or too defensive
TBH but since I'm sending the second one I'll include this as well..

This is an AI-generated review of your patch.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: stmmac: add stmmac core serdes support

This commit adds SerDes PHY support to the stmmac core driver, moving it
from platform glue into the integrated PCS driver. The serdes field in
platform data is optional and NULL when not provided by platforms.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 24a2555ca329..6c515f9efbe7 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -3549,12 +3550,16 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)
>
>  static void stmmac_clk_rx_i_require(struct stmmac_priv *priv)
>  {
> +	dwmac_serdes_power_on(priv);
> +	/* Only sets the SerDes mode if it wasn't already configured. */
> +	dwmac_serdes_init_mode(priv, priv->plat->phy_interface);

When priv->plat->serdes is NULL, dwmac_serdes_init_mode() will call
phy_get_mode(NULL). Unlike other phy_* functions (phy_power_on,
phy_power_off, phy_set_mode_ext, phy_init, phy_exit) which handle NULL
by returning early, phy_get_mode() is an inline that directly
dereferences the pointer:

    static inline enum phy_mode phy_get_mode(struct phy *phy)
    {
        return phy->attrs.mode;
    }

Can this NULL pointer dereference occur when a platform does not
populate plat->serdes? The call path stmmac_open() -> dwmac_serdes_init()
returns 0 (success) when serdes is NULL, allowing __stmmac_open() ->
stmmac_hw_setup() -> stmmac_clk_rx_i_require() to proceed.

> +	phylink_rx_clk_stop_block(priv->phylink);
>  }

[ ... ]

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c
> new file mode 100644
> index 000000000000..3003e1ae38d2
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c

[ ... ]

> +int dwmac_serdes_init(struct stmmac_priv *priv)
> +{
> +	size_t i;
> +	int ret;
> +
> +	if (!priv->plat->serdes)
> +		return 0;

This returns success when serdes is NULL...

[ ... ]

> +int dwmac_serdes_init_mode(struct stmmac_priv *priv, phy_interface_t interface)
> +{
> +	struct phy *serdes = priv->plat->serdes;
> +
> +	if (phy_get_mode(serdes) == PHY_MODE_ETHERNET)
                         ^^^^^^

...but dwmac_serdes_init_mode() has no NULL check before calling
phy_get_mode(), which will crash when serdes is NULL. Should this
function also check for NULL serdes before calling phy_get_mode()?

> +		return 0;
> +
> +	return dwmac_serdes_set_mode(priv, interface);
> +}

  parent reply	other threads:[~2026-01-16  2:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 17:44 [PATCH RFC net-next 00/14] net: stmmac: SerDes, PCS, BASE-X, and inband goodies Russell King (Oracle)
2026-01-14 17:45 ` [PATCH net-next 01/14] net: stmmac: qcom-ethqos: remove mac_base Russell King (Oracle)
2026-01-14 20:48   ` Vladimir Oltean
2026-01-14 17:45 ` [PATCH net-next 02/14] net: stmmac: qcom-ethqos: convert to set_clk_tx_rate() method Russell King (Oracle)
2026-01-14 17:45 ` [PATCH net-next 03/14] phy: qcom-sgmii-eth: add .set_mode() and .validate() methods Russell King (Oracle)
2026-01-14 18:47   ` Vladimir Oltean
2026-01-14 18:55     ` Russell King (Oracle)
2026-01-14 19:02       ` Vladimir Oltean
2026-01-15 10:11   ` kernel test robot
2026-01-15 10:23   ` kernel test robot
2026-01-14 17:45 ` [PATCH net-next 04/14] net: stmmac: wrap phylink's rx_clk_stop functions Russell King (Oracle)
2026-01-15 14:47   ` Maxime Chevallier
2026-01-14 17:45 ` [PATCH net-next 05/14] net: stmmac: add stmmac core serdes support Russell King (Oracle)
2026-01-15 14:48   ` Maxime Chevallier
2026-01-15 15:15     ` Russell King (Oracle)
2026-01-16  2:57   ` Jakub Kicinski [this message]
2026-01-14 17:45 ` [PATCH net-next 06/14] net: stmmac: qcom-ethqos: convert to dwmac generic SerDes support Russell King (Oracle)
2026-01-14 17:45 ` [PATCH net-next 07/14] net: stmmac: move most PCS register definitions to stmmac_pcs.c Russell King (Oracle)
2026-01-14 17:45 ` [PATCH net-next 08/14] net: stmmac: handle integrated PCS phy_intf_sel separately Russell King (Oracle)
2026-01-14 17:45 ` [PATCH net-next 09/14] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
2026-01-14 17:46 ` [PATCH net-next 10/14] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
2026-01-14 17:46 ` [PATCH net-next 11/14] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
2026-01-14 17:46 ` [PATCH net-next 12/14] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
2026-01-16  2:58   ` [net-next,12/14] " Jakub Kicinski
2026-01-14 17:46 ` [PATCH net-next 13/14] net: stmmac: configure SGMII AN control according to phylink Russell King (Oracle)
2026-01-14 17:46 ` [PATCH net-next 14/14] net: stmmac: report PCS configuration changes Russell King (Oracle)
  -- strict thread matches above, loose matches on Subject: below --
2026-01-19 12:34 [PATCH net-next 05/14] net: stmmac: add stmmac core serdes support Russell King (Oracle)
2026-01-19 19:21 ` [net-next,05/14] " Jakub Kicinski
2026-01-20  5:04   ` Russell King (Oracle)
2026-01-20  8:18     ` Vladimir Oltean
2026-01-20 10:12       ` Russell King (Oracle)
2026-01-20 12:11         ` Vladimir Oltean
2026-01-21 14:46           ` Russell King (Oracle)
2026-01-21 16:23             ` Vladimir Oltean
2026-01-21 17:33               ` Russell King (Oracle)
2026-01-22 11:29                 ` Vladimir Oltean
2026-01-20  8:42     ` Vladimir Oltean
2026-01-20 10:14       ` Russell King (Oracle)
2026-01-20 23:32     ` Jakub Kicinski

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=20260116025723.354031-2-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mohd.anwar@oss.qualcomm.com \
    --cc=neil.armstrong@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vkoul@kernel.org \
    /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