From: sashiko-bot@kernel.org
To: "Vladimir Oltean" <vladimir.oltean@nxp.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-phy@lists.infradead.org, olteanv@gmail.com,
vkoul@kernel.org, neil.armstrong@linaro.org
Subject: Re: [PATCH v3 phy-next 5/8] soc: fsl: guts: make fsl_soc_data available after fsl_guts_init()
Date: Mon, 20 Jul 2026 13:58:38 +0000 [thread overview]
Message-ID: <20260720135838.94D9F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720133642.136324-6-vladimir.oltean@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] NULL pointer dereference in the error handling path of `fsl_guts_init()`.
--
--- Patch [5]: [PATCH v3 phy-next 5/8] soc: fsl: guts: make fsl_soc_data available after fsl_guts_init() ---
commit d316b69e1c587b56ad6f914ddbd2e412490c8594
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
soc: fsl: guts: make fsl_soc_data available after fsl_guts_init()
This commit preserves the soc_data determined during fsl_guts_init() so it
can be referenced later for RCW override methods. It updates the error
handling paths to properly clean up the saved state if initialization fails.
> diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
> --- a/drivers/soc/fsl/guts.c
> +++ b/drivers/soc/fsl/guts.c
> @@ -231,10 +232,9 @@ static int __init fsl_guts_init(void)
> {
> - struct soc_device_attribute *soc_dev_attr;
> + struct soc_device_attribute *soc_dev_attr = NULL;
> static struct soc_device *soc_dev;
[ ... ]
> @@ -243,12 +243,12 @@ static int __init fsl_guts_init(void)
> np = of_find_matching_node_and_match(NULL, fsl_guts_of_match, &match);
> if (!np)
> return 0;
> - soc_data = match->data;
> + soc.data = match->data;
>
> soc.dcfg_ccsr = of_iomap(np, DCFG_CCSR);
> if (!soc.dcfg_ccsr) {
> of_node_put(np);
> - return -ENOMEM;
> + goto err_nomem;
> }
[Severity: High]
If of_iomap() fails here, the code executes a goto to the error path while
soc_dev_attr is still explicitly NULL.
Down in the error cleanup path, the code unconditionally dereferences
soc_dev_attr to retrieve its members:
> @@ -311,8 +311,11 @@ static int __init fsl_guts_init(void)
> kfree(soc_dev_attr->revision);
> kfree(soc_dev_attr->serial_number);
> kfree(soc_dev_attr);
Will this trigger a NULL pointer dereference?
While kfree() itself handles NULL pointers gracefully, evaluating
soc_dev_attr->revision and soc_dev_attr->serial_number requires reading
memory from the NULL soc_dev_attr pointer before passing the argument to
kfree().
> - iounmap(soc.dcfg_ccsr);
> - soc.dcfg_ccsr = NULL;
> + if (soc.dcfg_ccsr) {
> + iounmap(soc.dcfg_ccsr);
> + soc.dcfg_ccsr = NULL;
> + }
> + soc.data = NULL;
>
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720133642.136324-1-vladimir.oltean@nxp.com?part=5
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Vladimir Oltean" <vladimir.oltean@nxp.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-phy@lists.infradead.org, olteanv@gmail.com,
vkoul@kernel.org, neil.armstrong@linaro.org
Subject: Re: [PATCH v3 phy-next 5/8] soc: fsl: guts: make fsl_soc_data available after fsl_guts_init()
Date: Mon, 20 Jul 2026 13:58:38 +0000 [thread overview]
Message-ID: <20260720135838.94D9F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720133642.136324-6-vladimir.oltean@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] NULL pointer dereference in the error handling path of `fsl_guts_init()`.
--
--- Patch [5]: [PATCH v3 phy-next 5/8] soc: fsl: guts: make fsl_soc_data available after fsl_guts_init() ---
commit d316b69e1c587b56ad6f914ddbd2e412490c8594
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
soc: fsl: guts: make fsl_soc_data available after fsl_guts_init()
This commit preserves the soc_data determined during fsl_guts_init() so it
can be referenced later for RCW override methods. It updates the error
handling paths to properly clean up the saved state if initialization fails.
> diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
> --- a/drivers/soc/fsl/guts.c
> +++ b/drivers/soc/fsl/guts.c
> @@ -231,10 +232,9 @@ static int __init fsl_guts_init(void)
> {
> - struct soc_device_attribute *soc_dev_attr;
> + struct soc_device_attribute *soc_dev_attr = NULL;
> static struct soc_device *soc_dev;
[ ... ]
> @@ -243,12 +243,12 @@ static int __init fsl_guts_init(void)
> np = of_find_matching_node_and_match(NULL, fsl_guts_of_match, &match);
> if (!np)
> return 0;
> - soc_data = match->data;
> + soc.data = match->data;
>
> soc.dcfg_ccsr = of_iomap(np, DCFG_CCSR);
> if (!soc.dcfg_ccsr) {
> of_node_put(np);
> - return -ENOMEM;
> + goto err_nomem;
> }
[Severity: High]
If of_iomap() fails here, the code executes a goto to the error path while
soc_dev_attr is still explicitly NULL.
Down in the error cleanup path, the code unconditionally dereferences
soc_dev_attr to retrieve its members:
> @@ -311,8 +311,11 @@ static int __init fsl_guts_init(void)
> kfree(soc_dev_attr->revision);
> kfree(soc_dev_attr->serial_number);
> kfree(soc_dev_attr);
Will this trigger a NULL pointer dereference?
While kfree() itself handles NULL pointers gracefully, evaluating
soc_dev_attr->revision and soc_dev_attr->serial_number requires reading
memory from the NULL soc_dev_attr pointer before passing the argument to
kfree().
> - iounmap(soc.dcfg_ccsr);
> - soc.dcfg_ccsr = NULL;
> + if (soc.dcfg_ccsr) {
> + iounmap(soc.dcfg_ccsr);
> + soc.dcfg_ccsr = NULL;
> + }
> + soc.data = NULL;
>
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720133642.136324-1-vladimir.oltean@nxp.com?part=5
next prev parent reply other threads:[~2026-07-20 13:58 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 13:36 [PATCH v3 phy-next 0/8] RCW override for 10G Lynx dynamic protocol reconfiguration Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:36 ` [PATCH v3 phy-next 1/8] soc: fsl: guts: use a macro to encode the DCFG CCSR space Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:36 ` [PATCH v3 phy-next 2/8] soc: fsl: guts: add a global structure to hold state Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:50 ` sashiko-bot
2026-07-20 13:50 ` sashiko-bot
2026-07-20 14:01 ` Vladimir Oltean
2026-07-20 14:01 ` Vladimir Oltean
2026-07-20 14:57 ` Vladimir Oltean
2026-07-20 14:57 ` Vladimir Oltean
2026-07-21 8:44 ` Michael Walle
2026-07-21 8:44 ` Michael Walle
2026-07-21 10:43 ` Vladimir Oltean
2026-07-21 10:43 ` Vladimir Oltean
2026-07-20 13:36 ` [PATCH v3 phy-next 3/8] soc: fsl: guts: add a central fsl_guts_read() function Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:51 ` sashiko-bot
2026-07-20 13:51 ` sashiko-bot
2026-07-20 13:36 ` [PATCH v3 phy-next 4/8] soc: fsl: guts: make it easier to determine on which SoC we are running Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:53 ` sashiko-bot
2026-07-20 13:53 ` sashiko-bot
2026-07-20 13:36 ` [PATCH v3 phy-next 5/8] soc: fsl: guts: make fsl_soc_data available after fsl_guts_init() Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:58 ` sashiko-bot [this message]
2026-07-20 13:58 ` sashiko-bot
2026-07-20 13:36 ` [PATCH v3 phy-next 6/8] dt-bindings: fsl: layerscape-dcfg: define DCFG_DCSR region Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 13:57 ` sashiko-bot
2026-07-20 13:57 ` sashiko-bot
2026-07-20 13:36 ` [PATCH v3 phy-next 7/8] soc: fsl: guts: implement the RCW override procedure Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 14:03 ` sashiko-bot
2026-07-20 14:03 ` sashiko-bot
2026-07-20 13:36 ` [PATCH v3 phy-next 8/8] phy: lynx-10g: use RCW override procedure for dynamic protocol change Vladimir Oltean
2026-07-20 13:36 ` Vladimir Oltean
2026-07-20 14:13 ` sashiko-bot
2026-07-20 14:13 ` sashiko-bot
2026-07-20 16:34 ` Vinod Koul
2026-07-20 16:34 ` Vinod Koul
2026-07-20 20:12 ` Vladimir Oltean
2026-07-20 20:12 ` 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=20260720135838.94D9F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--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.