netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Alexander Couzens" <lynxis@fe80.eu>,
	"Alexander Duyck" <alexanderduyck@fb.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Arınç ÜNAL" <arinc.unal@arinc9.com>,
	"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	"Daniel Golle" <daniel@makrotopia.org>,
	"Daniel Machon" <daniel.machon@microchip.com>,
	"David S. Miller" <davem@davemloft.net>,
	"DENG Qingfang" <dqfext@gmail.com>,
	"Eric Dumazet" <edumazet@google.com>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	"Ioana Ciornei" <ioana.ciornei@nxp.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Jose Abreu" <Jose.Abreu@synopsys.com>,
	kernel-team@meta.com, "Lars Povlsen" <lars.povlsen@microchip.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	"Madalin Bucur" <madalin.bucur@nxp.com>,
	"Marcin Wojtas" <marcin.s.wojtas@gmail.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Michal Simek" <michal.simek@amd.com>,
	netdev@vger.kernel.org,
	"Nicolas Ferre" <nicolas.ferre@microchip.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Radhey Shyam Pandey" <radhey.shyam.pandey@amd.com>,
	"Sean Anderson" <sean.anderson@seco.com>,
	"Sean Wang" <sean.wang@mediatek.com>,
	"Steen Hegelund" <Steen.Hegelund@microchip.com>,
	"Taras Chornyi" <taras.chornyi@plvision.eu>,
	UNGLinuxDriver@microchip.com,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"Eric Woudstra" <ericwouds@gmail.com>
Subject: Re: [PATCH net-next 1/5] net: phylink: use pcs_neg_mode in phylink_mac_pcs_get_state()
Date: Thu, 9 Jan 2025 17:02:22 +0000	[thread overview]
Message-ID: <20250109170222.GM7706@kernel.org> (raw)
In-Reply-To: <E1tVuFh-000BXQ-D7@rmk-PC.armlinux.org.uk>

On Thu, Jan 09, 2025 at 03:15:17PM +0000, Russell King (Oracle) wrote:
> As in-band AN no longer just depends on MLO_AN_INBAND + Autoneg bit,
> we need to take account of the pcs_neg_mode when deciding how to
> initialise the speed, duplex and pause state members before calling
> into the .pcs_neg_mode() method. Add this.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/phy/phylink.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 31754d5fd659..d08cdbbbbc1e 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1492,12 +1492,24 @@ static int phylink_change_inband_advert(struct phylink *pl)
>  static void phylink_mac_pcs_get_state(struct phylink *pl,
>  				      struct phylink_link_state *state)
>  {
> +	struct phylink_pcs *pcs;
> +	bool autoneg;
> +
>  	linkmode_copy(state->advertising, pl->link_config.advertising);
>  	linkmode_zero(state->lp_advertising);
>  	state->interface = pl->link_config.interface;
>  	state->rate_matching = pl->link_config.rate_matching;
> -	if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> -			      state->advertising)) {
> +	state->an_complete = 0;
> +	state->link = 1;
> +
> +	pcs = pl->pcs;
> +	if (pcs->neg_mode)
> +		autoneg = pl->pcs_neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
> +	else
> +		autoneg = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> +					    state->advertising);
> +
> +	if (autoneg) {
>  		state->speed = SPEED_UNKNOWN;
>  		state->duplex = DUPLEX_UNKNOWN;
>  		state->pause = MLO_PAUSE_NONE;
> @@ -1506,11 +1518,9 @@ static void phylink_mac_pcs_get_state(struct phylink *pl,
>  		state->duplex = pl->link_config.duplex;
>  		state->pause = pl->link_config.pause;
>  	}
> -	state->an_complete = 0;
> -	state->link = 1;
>  
> -	if (pl->pcs)
> -		pl->pcs->ops->pcs_get_state(pl->pcs, state);
> +	if (pcs)
> +		pcs->ops->pcs_get_state(pcs, state);
>  	else
>  		state->link = 0;

Hi Russell,

Here it is assumed that pcs may be NULL.
But it is dereferenced unconditionally immediately
after it is assigned above.

This seems inconsistent.

Flagged by Smatch.

>  }
> -- 
> 2.30.2
> 
> 

  reply	other threads:[~2025-01-09 17:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 15:15 [PATCH net-next 0/5] net: phylink: fix PCS without autoneg Russell King (Oracle)
2025-01-09 15:15 ` [PATCH net-next 1/5] net: phylink: use pcs_neg_mode in phylink_mac_pcs_get_state() Russell King (Oracle)
2025-01-09 17:02   ` Simon Horman [this message]
2025-01-09 15:15 ` [PATCH net-next 2/5] net: phylink: pass neg_mode into .pcs_get_state() method Russell King (Oracle)
2025-01-09 15:15 ` [PATCH net-next 3/5] net: phylink: pass neg_mode into c22 state decoder Russell King (Oracle)
2025-01-09 15:15 ` [PATCH net-next 4/5] net: phylink: use neg_mode in phylink_mii_c22_pcs_decode_state() Russell King (Oracle)
2025-01-09 15:15 ` [PATCH net-next 5/5] net: phylink: provide fixed state for 1000base-X and 2500base-X Russell King (Oracle)
2025-01-10  8:04   ` Eric Woudstra
2025-01-10 11:14     ` Russell King (Oracle)
2025-01-13  9:21 ` [PATCH net-next v2 0/5] net: phylink: fix PCS without autoneg Russell King (Oracle)
2025-01-13 10:14   ` Russell King (Oracle)
2025-01-14 10:59   ` Eric Woudstra
2025-01-14 11:14     ` Russell King (Oracle)

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=20250109170222.GM7706@kernel.org \
    --to=horms@kernel.org \
    --cc=Jose.Abreu@synopsys.com \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexanderduyck@fb.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=arinc.unal@arinc9.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=daniel.machon@microchip.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=dqfext@gmail.com \
    --cc=edumazet@google.com \
    --cc=ericwouds@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lynxis@fe80.eu \
    --cc=madalin.bucur@nxp.com \
    --cc=marcin.s.wojtas@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=sean.anderson@seco.com \
    --cc=sean.wang@mediatek.com \
    --cc=taras.chornyi@plvision.eu \
    /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;
as well as URLs for NNTP newsgroup(s).