From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: sashiko-reviews@lists.linux.dev
Cc: vkoul@kernel.org, neil.armstrong@linaro.org, olteanv@gmail.com,
linux-phy@lists.infradead.org
Subject: Re: [PATCH phy-next 09/13] phy: lynx-28g: common probe() and remove()
Date: Fri, 29 May 2026 15:47:36 +0300 [thread overview]
Message-ID: <20260529124736.k63pevj6v6qqi4hw@skbuf> (raw)
In-Reply-To: <20260528180215.9B1D41F000E9@smtp.kernel.org>
On Thu, May 28, 2026 at 06:02:15PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Missing NULL check for the result of `of_device_get_match_data(dev)`.
> --
>
> commit 4307af42a82313eaf19153e90d7c48e0bd5f9626
> Author: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> phy: lynx-28g: common probe() and remove()
>
> Factor the device-agnostic logic from lynx_28g_probe() and
> lynx_28g_remove() into lynx_probe() and lynx_remove() inside
> phy-fsl-lynx-core.c. These will be shared with the 10G Lynx driver.
>
> > diff --git a/drivers/phy/freescale/phy-fsl-lynx-28g.c b/drivers/phy/freescale/phy-fsl-lynx-28g.c
> > --- a/drivers/phy/freescale/phy-fsl-lynx-28g.c
> > +++ b/drivers/phy/freescale/phy-fsl-lynx-28g.c
> [ ... ]
> > static int lynx_28g_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > + const struct lynx_info *info;
> >
> > /*
> > * If we get here it means we probed on a device tree where
> > * "fsl,lynx-28g" wasn't the fallback, but the sole compatible string.
> > */
> > + info = of_device_get_match_data(dev);
>
> [Severity: High]
> This is a pre-existing issue, but should we check if info is NULL before
> proceeding?
>
> If a user binds the driver to a device using the sysfs bind interface, and
> the device's OF node does not match the driver's of_match_table,
> of_device_get_match_data() will return NULL.
>
> > + if (info == &lynx_info_compat)
> > dev_warn(dev, "Please update device tree to use per-device compatible strings\n");
> >
> > + return lynx_probe(pdev, info, &lynx_28g_ops);
> > }
>
> [ ... ]
> > diff --git a/drivers/phy/freescale/phy-fsl-lynx-core.c b/drivers/phy/freescale/phy-fsl-lynx-core.c
> > --- a/drivers/phy/freescale/phy-fsl-lynx-core.c
> > +++ b/drivers/phy/freescale/phy-fsl-lynx-core.c
> [ ... ]
> > +int lynx_probe(struct platform_device *pdev, const struct lynx_info *info,
> > + const struct phy_ops *phy_ops)
> > +{
> [ ... ]
> > + priv->dev = dev;
> > + priv->info = info;
> > + dev_set_drvdata(dev, priv);
> > + spin_lock_init(&priv->pcc_lock);
> > + INIT_DELAYED_WORK(&priv->cdr_check, lynx_cdr_lock_check);
> > +
> > + priv->lane = devm_kcalloc(dev, priv->info->num_lanes,
>
> [Severity: High]
> This isn't a bug introduced by this patch, but if info was NULL as mentioned
> above, would this unconditionally dereference it and cause a kernel panic?
>
> > + sizeof(*priv->lane), GFP_KERNEL);
> > + if (!priv->lane)
> > + return -ENOMEM;
> [ ... ]
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260528172404.733196-1-vladimir.oltean@nxp.com?part=9
This seems to be true. I was able to trigger a kernel oops by running:
$ echo 1ea0000.phy > /sys/bus/platform/drivers/lynx-10g/unbind
$ echo lynx-28g > /sys/bus/platform/devices/1ea0000.phy/driver_override
$ echo 1ea0000.phy > /sys/bus/platform/drivers/lynx-28g/bind
Internal error: Oops: 0000000096000004 [#1] SMP
Hardware name: LS1028A RDB Board (DT)
pc : lynx_probe+0x118/0x4fc
lr : lynx_probe+0x110/0x4fc
Call trace:
lynx_probe+0x118/0x4fc (P)
lynx_28g_probe+0x54/0x7c
platform_probe+0x68/0xa4
really_probe+0x14c/0x2ec
__driver_probe_device+0xc8/0x170
device_driver_attach+0x58/0xa8
bind_store+0xd8/0x118
drv_attr_store+0x24/0x38
It seems driver_override is a huge foot gun, which probably many drivers
are vulnerable to. I will include a patch protecting from this in the
next series.
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-05-29 12:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 17:23 [PATCH phy-next 00/13] New Generic PHY driver for Lynx 10G SerDes Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 01/13] dt-bindings: phy: lynx-10g: initial document Vladimir Oltean
2026-05-28 17:40 ` sashiko-bot
2026-05-28 17:45 ` Vladimir Oltean
2026-05-29 12:50 ` Vladimir Oltean
2026-06-05 19:04 ` Rob Herring (Arm)
2026-05-28 17:23 ` [PATCH phy-next 02/13] phy: lynx-28g: move lane mode helpers to new core module Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 03/13] phy: lynx-28g: move data structures to core Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 04/13] phy: lynx-28g: common lynx_pll_get() Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 05/13] phy: lynx-28g: generalize protocol converter accessors Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 06/13] phy: lynx-28g: provide default lynx_lane_supports_mode() implementation Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 07/13] phy: lynx-28g: move struct lynx_info definitions downwards Vladimir Oltean
2026-05-28 17:23 ` [PATCH phy-next 08/13] phy: lynx-28g: make lynx_28g_pll_read_configuration() callable per PLL Vladimir Oltean
2026-05-28 17:46 ` sashiko-bot
2026-05-28 17:24 ` [PATCH phy-next 09/13] phy: lynx-28g: common probe() and remove() Vladimir Oltean
2026-05-28 18:02 ` sashiko-bot
2026-05-29 12:47 ` Vladimir Oltean [this message]
2026-05-28 17:24 ` [PATCH phy-next 10/13] phy: lynx-28g: add support for big endian register maps Vladimir Oltean
2026-05-28 17:47 ` sashiko-bot
2026-05-29 12:00 ` Vladimir Oltean
2026-05-28 17:24 ` [PATCH phy-next 11/13] phy: lynx-28g: optimize read-modify-write operation Vladimir Oltean
2026-05-28 17:24 ` [PATCH phy-next 12/13] phy: lynx-10g: new driver Vladimir Oltean
2026-05-28 18:20 ` sashiko-bot
2026-05-29 12:34 ` Vladimir Oltean
2026-05-28 17:24 ` [PATCH phy-next 13/13] MAINTAINERS: expand Lynx 28G entry to cover Lynx 10G SerDes Vladimir Oltean
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=20260529124736.k63pevj6v6qqi4hw@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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