mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kyle.switch@motor-comm.com
Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	mmyangfl@gmail.com, horms@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	ming.xu@motor-comm.com, xiaolin.xu@motor-comm.com,
	jianmin.wang@motor-comm.com, wei.zhang@gl-inet.com,
	sijia.huang@gl-inet.com
Subject: Re: [PATCH net-next v16 1/5] net: dsa: motorcomm: initialize dsa_switch based on chipid
Date: Thu, 22 Oct 2026 02:11:22 +0000	[thread overview]
Message-ID: <179263508238.3135.2126359044683205033@kernel.org> (raw)
In-Reply-To: <20261020111115.3072180-2-kyle.switch@motor-comm.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] When yt921x_reg_read(priv, YT921X_CHIP_ID, &chipid) fails,
  yt92xx_register_switch() (drivers/net/dsa/motorcomm/chip.c) prints…

--

net: dsa: motorcomm: initialize dsa_switch based on chipid

This patch replaces the hardcoded dsa_switch setup in yt921x_mdio_probe()
with a new helper, yt92xx_register_switch(). The helper reads the chip ID,
looks up a per-series descriptor table and fills in the dsa_switch fields
from that descriptor.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index d4fc20c52a58d..4add61b89310a 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c

[ ... ]

> +static int yt92xx_register_switch(struct dsa_switch *ds)
> +{
> +	struct yt921x_priv *priv = dsa_to_yt921x_priv(ds);
> +	struct device *dev = yt921x_priv_to_device(priv);
> +	const struct yt92xx_series *series;
> +	u32 chipid;
> +	u32 major;
> +	int res;
> +
> +	mutex_lock(&priv->reg_lock);
> +	res = yt921x_reg_read(priv, YT921X_CHIP_ID, &chipid);
> +	mutex_unlock(&priv->reg_lock);
> +	if (res) {
> +		dev_err(dev, "Unexpected chipid 0x%x\n", chipid);
                                                          ^^^^^^

[Severity: Low]
Can this print an uninitialized value?

chipid is a local u32 with no initializer. This dev_err() only runs when
yt921x_reg_read() has failed. With the MDIO backend, the output pointer is
written only on success. Every error path jumps over the store:

drivers/net/dsa/motorcomm/chip.c:yt921x_reg_mdio_read() {
    ...
	res = __mdiobus_read(bus, addr, reg_data);
	if (res < 0)
		goto end;
	val = (val << 16) | (u16)res;

	*valp = val;
	res = 0;

end:
	mutex_unlock(&bus->mdio_lock);
	return res;
}

So if an MDIO error happens during yt921x_mdio_probe(), the log line will
show leftover stack contents. The wording also suggests a bad ID was read,
when in fact the read failed.

The same string in yt921x_chip_detect() is printed only after a successful
read, when the major is not recognized.

Could the read-failure path just return res, or print a message that does
not use chipid?

It looks like the final patch of this series, "net: dsa: motorcomm: Add
support for Motorcomm YT922x", rewrites this branch as a plain "if (res)
return res;". After that change, chipid is printed only on the unknown-major
path. The intermediate patches in the series still contain this code.

> +		return res;
> +	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261020111115.3072180-1-kyle.switch%40motor-comm.com

  reply	other threads:[~2026-10-22  2:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 11:11 [PATCH net-next v16 0/5] net: dsa: motorcomm: add support yt922x driver Kyle Switch
2026-10-20 11:11 ` [PATCH net-next v16 1/5] net: dsa: motorcomm: initialize dsa_switch based on chipid Kyle Switch
2026-10-22  2:11   ` netdev-bot+sashiko [this message]
2026-10-20 11:11 ` [PATCH net-next v16 2/5] net: dsa: motorcomm: use max_ports in series for port bounds checking Kyle Switch
2026-10-20 11:11 ` [PATCH net-next v16 3/5] net: dsa: motorcomm: use fixed-width GENMASK_U*() helpers Kyle Switch
2026-10-22  2:11   ` netdev-bot+sashiko
2026-10-20 11:11 ` [PATCH net-next v16 4/5] net: dsa: tag_yt922x: add support for Motorcomm YT922x tags Kyle Switch
2026-10-22  2:11   ` netdev-bot+sashiko
2026-10-20 11:11 ` [PATCH net-next v16 5/5] net: dsa: motorcomm: Add support for Motorcomm YT922x Kyle Switch
2026-10-22  2:11   ` netdev-bot+sashiko
2026-10-21  1:30 ` [PATCH net-next v16 0/5] net: dsa: motorcomm: add support yt922x driver 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=179263508238.3135.2126359044683205033@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jianmin.wang@motor-comm.com \
    --cc=kuba@kernel.org \
    --cc=kyle.switch@motor-comm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ming.xu@motor-comm.com \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=sijia.huang@gl-inet.com \
    --cc=wei.zhang@gl-inet.com \
    --cc=xiaolin.xu@motor-comm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®