Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: mfd@lists.linux.dev, devicetree@vger.kernel.org, lee@kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v23 9/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver
Date: Sat, 26 Sep 2026 18:25:23 +0000	[thread overview]
Message-ID: <20260926182523.ACB681F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260925182435.21207-10-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] net: dsa: NULL deref in mt7530_lib_fdb_read() due to mismatched field check
- [Medium] net: dsa: ethtool -S stat duplication for standard uAPI counters
- [Medium] net: dsa: stale tx_lpi_timer_ports values corrupt global LPI timer calculation
--

commit 6c2fcaf5228ec0a75518542784a8b035277e4900
Author: Christian Marangi <ansuelsmth@gmail.com>
Subject: net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver

This introduces the driver for the Airoha AN8855 5-Port Gigabit DSA switch.
It supports multiple Ethernet speeds up to 2.5G and includes necessary
adjustments to the mt7530-lib to support Airoha structures.

> diff --git a/drivers/net/dsa/an8855.c b/drivers/net/dsa/an8855.c
> index 0000000000000..428d7dd85dd80
> --- /dev/null
> +++ b/drivers/net/dsa/an8855.c
[ ... ]
> +static const struct mt7530_mib_desc an8855_mib[] = {
> +	MIB_DESC(MT7530_MIB_TX_DROP, -1, "TxDrop"),
> +	MIB_DESC(MT7530_MIB_TX_CRC_ERR, -1, "TxCrcErr"),

[Severity: Medium]
Are these standard networking statistics meant to be duplicated as
driver-private ethtool -S strings here? Standard counters already have a
defined uAPI, and duplicating them in private strings exposes redundant
data to userspace tools.

[ ... ]
> +static void an8855_get_strings(struct dsa_switch *ds, int port,
> +			       u32 stringset, uint8_t *data)
> +{
> +	int i;
> +
> +	if (stringset != ETH_SS_STATS)
> +		return;
> +
> +	for (i = 0; i < ARRAY_SIZE(an8855_mib); i++)
> +		ethtool_puts(&data, an8855_mib[i].name);
> +}

[Severity: Medium]
Since the statistics mapped in an8855_mib[] overlap with standard uAPI
counters, doesn't exposing them here violate kernel networking guidelines
for ethtool -S statistics?

[ ... ]
> +static void an8855_phylink_mac_disable_tx_lpi(struct phylink_config *config)
> +{
> +	struct dsa_port *dp = dsa_phylink_to_port(config);
> +	struct an8855_priv *priv = dp->ds->priv;
> +	int port = dp->index;
> +	int ret;
> +
> +	mutex_lock(&priv->reg_mutex);
> +	ret = regmap_clear_bits(priv->regmap, AN8855_PMCR_P(port),
> +				AN8855_PMCR_FORCE_EEE1G |
> +				AN8855_PMCR_FORCE_EEE100);
> +	mutex_unlock(&priv->reg_mutex);

[Severity: Medium]
When EEE is disabled on a port here, shouldn't we also clear the software
state for the timer (priv->tx_lpi_timer_ports[port] = 0)? 

[ ... ]
> +static int an8855_phylink_mac_enable_tx_lpi(struct phylink_config *config,
> +					    u32 timer, bool tx_clock_stop)
> +{
[ ... ]
> +	if (timer) {
> +		int i;
> +
> +		/* Save requested timer and search the highest one */
> +		mutex_lock(&priv->reg_mutex);
> +		priv->tx_lpi_timer_ports[dp->index] = timer;
> +		for (i = 0; i < AN8855_NUM_PORTS; i++) {
> +			if (!priv->ports[i].enable)
> +				continue;
> +
> +			if (i == dp->index)
> +				continue;
> +
> +			if (timer < priv->tx_lpi_timer_ports[i])
> +				timer = priv->tx_lpi_timer_ports[i];
> +		}

[Severity: Medium]
Because an8855_phylink_mac_disable_tx_lpi() doesn't clear the port's software
timer state, couldn't this loop evaluate stale timer values from ports where
EEE was previously disabled? Could this corrupt the global LPI timer
calculation?

> diff --git a/drivers/net/dsa/mt7530-lib.c b/drivers/net/dsa/mt7530-lib.c
> index 098dd45d3ee9f..cf474faf8ed6a 100644
> --- a/drivers/net/dsa/mt7530-lib.c
> +++ b/drivers/net/dsa/mt7530-lib.c
[ ... ]
> @@ -483,8 +497,14 @@ void mt7530_lib_fdb_read(struct mt7530_lib_priv *priv, struct mt7530_fdb *fdb)
>  	fdb->mac[1] = val;
>  	regmap_field_read(priv->fields[MT7530_ATRD_MAC_BYTE_0], &val);
>  	fdb->mac[0] = val;
> -	regmap_field_read(priv->fields[MT7530_ATRD_ENT_STATUS], &val);
> -	fdb->noarp = val == STATIC_ENT;
> +	if (priv->fields[MT7530_ATWD_ENT_STATUS]) {
> +		regmap_field_read(priv->fields[MT7530_ATRD_ENT_STATUS], &val);

[Severity: High]
Can this cause a NULL pointer dereference? The condition checks if the ATWD 
(write) field exists, but then unconditionally dereferences the ATRD (read) 
field. If a driver populates the ATWD field but omits the ATRD field, 
wouldn't regmap_field_read() crash?

> +		fdb->noarp = val == STATIC_ENT;
> +	}
> +	if (priv->fields[AN8855_ATRD_ARP]) {
> +		regmap_field_read(priv->fields[AN8855_ATRD_ARP], &val);
> +		fdb->noarp = !!val;
> +	}
>  }
>  EXPORT_SYMBOL_GPL(mt7530_lib_fdb_read);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260925182435.21207-1-ansuelsmth@gmail.com?part=9

  reply	other threads:[~2026-09-26 18:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 18:24 [PATCH net-next v23 0/9] net: dsa: Add Airoha AN8855 support Christian Marangi
2026-09-25 18:24 ` [PATCH net-next v23 1/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-25 18:24 ` [PATCH net-next v23 2/9] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-29 20:34   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 3/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 4/9] mfd: an8855: Add support for Airoha AN8855 Switch Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 18:45   ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 6/9] net: dsa: tag_mtk: add Airoha variant usage of this TAG Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 18:49   ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 7/9] MAINTAINERS: add myself as maintainer for Airoha AN8855 Switch Christian Marangi
2026-09-27 18:51   ` Andrew Lunn
2026-09-25 18:24 ` [PATCH net-next v23 8/9] net: dsa: mt7530: generalize and move common function to lib module Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 19:02   ` Andrew Lunn
2026-09-27 20:28     ` Christian Marangi
2026-09-27 21:48       ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 9/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2026-09-26 18:25   ` sashiko-bot [this message]
2026-09-27 19:15   ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko

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=20260926182523.ACB681F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --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