From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v16 02/12] net: phylink: introduce internal phylink PCS handling
Date: Fri, 18 Sep 2026 00:45:20 +0000 [thread overview]
Message-ID: <20260918004521.4B5DF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260916235200.20712-3-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] net: phylink_validate_mac_and_pcs() fails to return error when required PCS is missing
- [Medium] net: phylink_create() unsafely expands MAC supported interfaces with generic PCS capabilities
--
commit 5b275072f20518c6dfff0e7c6d9837800cd61c3e
Author: Christian Marangi <ansuelsmth@gmail.com>
net: phylink: introduce internal phylink PCS handling
This commit introduces internal handling of PCS for phylink, moving the PCS
selection logic entirely to phylink using the supported_interface value in
the PCS struct. This provides an alternative to the .mac_select_pcs callback.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index d67a5184c524f..417d2f1e54b72 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -530,6 +549,21 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
> pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
> if (IS_ERR(pcs))
> return PTR_ERR(pcs);
> + /*
> + * Find a PCS in available PCS list for the requested interface.
> + *
> + * Skip searching if the MAC doesn't require a dedicated PCS for
> + * the requested interface.
> + */
> + } else if (test_bit(state->interface, pl->config->pcs_interfaces)) {
> + struct phylink_pcs *tmp;
> +
> + list_for_each_entry(tmp, &pl->pcs_list, list) {
> + if (!phylink_validate_pcs_interface(tmp, state->interface)) {
> + pcs = tmp;
> + break;
> + }
> + }
> }
>
> if (pcs) {
[Severity: Medium]
If the requested interface requires a dedicated PCS (the pcs_interfaces bit
is set), but the loop finishes without finding a matching PCS in the
pcs_list, pcs will remain NULL. Should this code return an error here
rather than falling through?
If it doesn't return an error, phylink might falsely advertise unsupported
link modes during auto-negotiation, and later phylink_major_config() could
attempt to configure this mode, fail to find the required PCS, and fatally
abort configuration.
[ ... ]
> @@ -2031,16 +2150,31 @@ struct phylink *phylink_create(struct phylink_config *config,
> __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
> timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
>
> + /* Fill the PCS list with available PCS from phylink config */
> + ret = phylink_fill_available_pcs(pl, config);
> + if (ret < 0)
> + goto free_pl;
> +
> + /* Link available PCS to phylink */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + pcs->phylink = pl;
> +
> phy_interface_copy(pl->supported_interfaces,
> pl->config->supported_interfaces);
>
> + /* Update supported interfaces */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + phy_interface_or(pl->supported_interfaces,
> + pl->supported_interfaces,
> + pcs->supported_interfaces);
> +
[Severity: Medium]
Does this safely handle MAC capabilities, or could it incorrectly expand
the MAC's supported interfaces with generic PCS capabilities?
Generic PCS blocks often support interface modes that the specific MAC or
board trace routing does not. By ORing in all interfaces supported by the
attached PCS modules, this might cause phylink_validate() to incorrectly
accept unsupported interface modes (since MAC drivers often only check
speed/duplex in their mac_capabilities).
> linkmode_fill(pl->supported);
> linkmode_copy(pl->link_config.advertising, pl->supported);
> phylink_validate(pl, pl->supported, &pl->link_config);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916235200.20712-1-ansuelsmth@gmail.com?part=2
next prev parent reply other threads:[~2026-09-18 0:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 23:51 [PATCH net-next v16 00/12] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-09-16 23:51 ` [PATCH net-next v16 01/12] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-09-16 23:51 ` [PATCH net-next v16 02/12] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-09-18 0:45 ` sashiko-bot [this message]
2026-09-16 23:51 ` [PATCH net-next v16 03/12] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-09-18 0:45 ` sashiko-bot
2026-09-16 23:51 ` [PATCH net-next v16 04/12] net: phylink: save phylink instance fwnode on phylink_create Christian Marangi
2026-09-16 23:51 ` [PATCH net-next v16 05/12] net: phylink: support PCS provider release Christian Marangi
2026-09-18 0:45 ` sashiko-bot
2026-09-16 23:51 ` [PATCH net-next v16 06/12] net: phylink: support late PCS provider attach Christian Marangi
2026-09-18 0:45 ` sashiko-bot
2026-09-16 23:51 ` [PATCH net-next v16 07/12] net: Document PCS subsystem Christian Marangi
2026-09-18 0:45 ` sashiko-bot
2026-09-16 23:51 ` [PATCH net-next v16 08/12] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-09-16 23:51 ` [PATCH net-next v16 09/12] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-09-16 23:51 ` [PATCH net-next v16 10/12] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-09-24 22:17 ` Rob Herring (Arm)
2026-09-16 23:51 ` [PATCH net-next v16 11/12] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-09-18 0:45 ` sashiko-bot
2026-09-16 23:51 ` [PATCH net-next v16 12/12] net: airoha: add phylink support Christian Marangi
2026-09-21 20:59 ` [PATCH net-next v16 00/12] net: pcs: Introduce support for fwnode PCS Jakub Kicinski
2026-09-22 10:12 ` Christian Marangi (Ansuel)
2026-09-22 12:49 ` Maxime Chevallier
2026-09-22 13:26 ` Coia Prant
2026-09-23 0:25 ` Jakub Kicinski
2026-09-23 8:31 ` Christian Marangi (Ansuel)
2026-09-24 3:11 ` Jakub Kicinski
2026-09-24 8:03 ` Maxime Chevallier
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=20260918004521.4B5DF1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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