From: sashiko-bot@kernel.org
To: "David Yang" <mmyangfl@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v10 3/4] net: dsa: motorcomm: Add LED support
Date: Mon, 17 Aug 2026 19:39:58 +0000 [thread overview]
Message-ID: <20260817193958.E06111F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260816193905.218112-4-mmyangfl@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Unconditional kernel panic during probe due to pointer arithmetic on NULL net_device pointers in yt921x_cled_hw_control_get_device().
--
--- Patch [3]: [PATCH net-next v10 3/4] net: dsa: motorcomm: Add LED support ---
commit 25a5fb03fc03b52bd3ea80525b1fd57bd6de812d
Author: David Yang <mmyangfl@gmail.com>
net: dsa: motorcomm: Add LED support
This commit adds support for controlling the LEDs attached to the
Motorcomm YT9215 switch chips via the standard LEDs subsystem. It
currently supports parallel mode and strict 1:1 mapping.
> diff --git a/drivers/net/dsa/motorcomm/leds.c b/drivers/net/dsa/motorcomm/leds.c
> new file mode 100644
> index 0000000000000..e7ef0ef80a266
> --- /dev/null
> +++ b/drivers/net/dsa/motorcomm/leds.c
[ ... ]
> +static struct device * __maybe_unused
> +yt921x_cled_hw_control_get_device(struct led_classdev *led_cdev)
> +{
> + struct yt921x_led *led = to_yt921x_led(led_cdev);
> + struct yt921x_port *pp = to_yt921x_port(led);
> + struct yt921x_priv *priv = to_yt921x_priv(pp);
> + struct dsa_port *dp;
> +
> + dp = dsa_to_port(&priv->ds, pp->index);
> + if (!dp)
> + return NULL;
> +
> + if (dsa_port_is_user(dp))
> + return &dp->user->dev;
> + if (dsa_port_is_cpu(dp))
> + return &dp->conduit->dev;
[Severity: Critical]
Could this cause a kernel panic during probe if dp->user or dp->conduit is
NULL?
When the hw_control_trigger is set to netdev during driver setup, the LED
core immediately activates the netdev trigger, which in turn calls
yt921x_cled_hw_control_get_device().
At this point during probe, the user ports are not fully instantiated yet,
meaning dp->user is NULL. Unconditionally returning &dp->user->dev performs
pointer arithmetic on the NULL pointer, yielding a non-zero invalid pointer
because dev is located at an offset within struct net_device.
The netdev trigger core evaluates this pointer as true and calls to_net_dev()
on it, which subtracts the offset and yields exactly NULL. It then attempts
to dereference the network device name, crashing the kernel.
Does this need an explicit check to verify dp->user and dp->conduit are valid
pointers before accessing their dev members?
> +
> + return NULL;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260816193905.218112-1-mmyangfl@gmail.com?part=3
next prev parent reply other threads:[~2026-08-17 19:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 19:38 [PATCH net-next v10 0/4] net: dsa: motorcomm: Add LED support David Yang
2026-08-16 19:38 ` [PATCH net-next v10 1/4] net: dsa: motorcomm: Move to subdirectory David Yang
2026-08-16 19:38 ` [PATCH net-next v10 2/4] net: dsa: motorcomm: Split SMI module David Yang
2026-08-16 19:38 ` [PATCH net-next v10 3/4] net: dsa: motorcomm: Add LED support David Yang
2026-08-17 19:39 ` sashiko-bot [this message]
2026-08-16 19:38 ` [PATCH net-next v10 4/4] dt-bindings: net: dsa: yt921x: Add LEDs definition example David Yang
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=20260817193958.E06111F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=mmyangfl@gmail.com \
--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