All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Oltean" <vladimir.oltean@nxp.com>
Cc: vkoul@kernel.org, neil.armstrong@linaro.org, olteanv@gmail.com,
	linux-phy@lists.infradead.org
Subject: Re: [PATCH v5 phy-next 02/16] phy: lynx-28g: reject probing on devices with unsupported OF nodes
Date: Wed, 10 Jun 2026 15:38:35 +0000	[thread overview]
Message-ID: <20260610153836.1F5AF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610151952.2141019-3-vladimir.oltean@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing check for the return value of `of_device_get_match_data()` in `imx8_pcie_phy_probe` and `imx_hsio_probe` leads to NULL pointer dereference.
--

commit 11cd1431079ad06a01704502129a0983e1f3e992
Author: Vladimir Oltean <vladimir.oltean@nxp.com>

phy: lynx-28g: reject probing on devices with unsupported OF nodes

This commit fixes a potential NULL pointer dereference in the lynx-28g
driver when bound to arbitrary devices via driver_override. It adds a
check to ensure of_device_get_match_data() does not return NULL before
dereferencing the match data.

> diff --git a/drivers/phy/freescale/phy-fsl-lynx-28g.c b/drivers/phy/freescale/phy-fsl-lynx-28g.c
> index cacc128dc96a1..1f5cb02931f56 100644
> --- a/drivers/phy/freescale/phy-fsl-lynx-28g.c
> +++ b/drivers/phy/freescale/phy-fsl-lynx-28g.c
> @@ -1477,6 +1477,9 @@ static int lynx_28g_probe(struct platform_device *pdev)
>  
>  	priv->dev = dev;
>  	priv->info = of_device_get_match_data(dev);
> +	if (!priv->info)
> +		return -ENODEV;
> +
>  	dev_set_drvdata(dev, priv);

[Severity: High]
This isn't a bug introduced by this patch, but it appears the exact same
missing check exists in other drivers within the same subsystem.

Do we need to add similar NULL checks for of_device_get_match_data() in
imx8_pcie_phy_probe() to avoid a crash?

drivers/phy/freescale/phy-fsl-imx8m-pcie.c:imx8_pcie_phy_probe() {
    ...
    imx8_phy->drvdata = of_device_get_match_data(dev);
    ...
    imx8_phy->iomuxc_gpr =
         syscon_regmap_lookup_by_compatible(imx8_phy->drvdata->gpr);
    ...
}

And also in imx_hsio_probe() where it accesses the lane_num field?

drivers/phy/freescale/phy-fsl-imx8qm-hsio.c:imx_hsio_probe() {
    ...
    priv->drvdata = of_device_get_match_data(dev);
    ...
    for (i = 0; i < priv->drvdata->lane_num; i++) {
    ...
}

Without a check, could these drivers similarly crash with a NULL pointer
dereference when bound to a device with a different compatible string via
the driver_override interface?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260610151952.2141019-1-vladimir.oltean@nxp.com?part=2

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-06-10 15:38 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 15:19 [PATCH v5 phy-next 00/16] New Generic PHY driver for Lynx 10G SerDes Vladimir Oltean
2026-06-10 15:19 ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 01/16] phy: lynx-28g: avoid returning NULL in of_xlate() function Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 02/16] phy: lynx-28g: reject probing on devices with unsupported OF nodes Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:38   ` sashiko-bot [this message]
2026-06-10 15:19 ` [PATCH v5 phy-next 03/16] phy: lynx-28g: move lane mode helpers to new core module Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:44   ` sashiko-bot
2026-06-10 15:19 ` [PATCH v5 phy-next 04/16] phy: lynx-28g: move data structures to core Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 05/16] phy: lynx-28g: common lynx_pll_get() Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 06/16] phy: lynx-28g: generalize protocol converter accessors Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 07/16] phy: lynx-28g: provide default lynx_lane_supports_mode() implementation Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 08/16] phy: lynx-28g: move struct lynx_info definitions downwards Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 09/16] phy: lynx-28g: make lynx_28g_pll_read_configuration() callable per PLL Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 10/16] phy: lynx-28g: common probe() and remove() Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 11/16] phy: lynx-28g: add support for big endian register maps Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 16:33   ` sashiko-bot
2026-06-10 15:19 ` [PATCH v5 phy-next 12/16] phy: lynx-28g: optimize read-modify-write operation Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 13/16] phy: lynx-28g: improve phy_validate() procedure Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 14/16] dt-bindings: phy: lynx-10g: initial document Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 15/16] phy: lynx-10g: new driver Vladimir Oltean
2026-06-10 15:19   ` Vladimir Oltean
2026-06-10 15:19 ` [PATCH v5 phy-next 16/16] MAINTAINERS: expand Lynx 28G entry to cover Lynx 10G SerDes Vladimir Oltean
2026-06-10 15:19   ` 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=20260610153836.1F5AF1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --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 \
    --cc=vladimir.oltean@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.