Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hongliang Yang" <hongliang.yang@cixtech.com>
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v9 2/2] usb: cdns3: Add CIX Sky1 glue driver
Date: Tue, 17 Nov 2026 03:15:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-218132@kernel.org> (raw)
In-Reply-To: <20261117021705.2202892-3-hongliang.yang@cixtech.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: cdns3: cdnsp-sky1: pdata leak and silent child failure
  in cdnsp_sky1_probe()
--

commit c575d53bf0eb9b8bf707582d20e9f670aee59e99
Author: Hongliang Yang <hongliang.yang@cixtech.com>

usb: cdns3: Add CIX Sky1 glue driver

This commit adds a glue layer driver for the Cadence USBSSP controller on
the CIX Sky1 SoC, managing its clocks, resets, mode straps, and child
device creation.

> diff --git a/drivers/usb/cdns3/cdnsp-sky1.c b/drivers/usb/cdns3/cdnsp-sky1.c
> new file mode 100644
> index 0000000000000..7738ac7268de6
> --- /dev/null
> +++ b/drivers/usb/cdns3/cdnsp-sky1.c
[ ... ]
> +static int cdnsp_sky1_probe(struct platform_device *pdev)
> +{
[ ... ]
> +	/*
> +	 * platform_device_release() kfree()s dev.platform_data, so this
> +	 * buffer belongs to the child device once it is created. It cannot be
> +	 * devm-managed. cdnsp_sky1_check_children() guarantees that exactly one
> +	 * child takes it over, so it is not released here, not even on failure:
> +	 * a child that was created and then failed to register frees it on its
> +	 * own.
> +	 */
> +	cdns_sky1_pdata = kzalloc(sizeof(*cdns_sky1_pdata), GFP_KERNEL);
> +	if (!cdns_sky1_pdata) {
> +		ret = -ENOMEM;
> +		goto err_quiesce;
> +	}
> +	cdns_sky1_pdata->platform_suspend = cdns_sky1_platform_suspend;
> +	cdns_sky1_pdata->quirks = CDNS3_DEFAULT_PM_RUNTIME_ALLOW;
> +	cdns_sky1_auxdata[0].platform_data = cdns_sky1_pdata;
> +	ret = of_platform_populate(node, NULL, cdns_sky1_auxdata, dev);
> +	if (ret) {
> +		dev_err(dev, "failed to create children: %d\n", ret);
> +		goto err_quiesce;
> +	}

[Severity: Medium]
Can this leak cdns_sky1_pdata and silently succeed when creating the child
device fails?

drivers/of/platform.c:of_platform_device_create_pdata() {
	if (!of_device_is_available(np) ||
	    of_node_test_and_set_flag(np, OF_POPULATED))
		return NULL;

	dev = of_device_alloc(np, bus_id, parent);
	if (!dev)
		goto err_clear_flag;
	...
	dev->dev.platform_data = platform_data;
}

drivers/of/platform.c:of_platform_bus_create() {
	dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
	if (!dev || !of_match_node(matches, bus))
		return 0;
}

If of_device_alloc() fails (or OF_POPULATED is already set),
dev->dev.platform_data is never assigned, so platform_device_release()
never frees cdns_sky1_pdata.  In addition, of_platform_bus_create()
returns 0 when of_platform_device_create_pdata() returns NULL, so
of_platform_populate() only returns a non-zero error before any child is
created (such as -ENODEV when CONFIG_OF_ADDRESS is disabled), leaking
cdns_sky1_pdata on the goto err_quiesce path as well, while a child
creation failure causes cdnsp_sky1_probe() to return 0 with no child
device registered and the clocks and resets left active.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117021705.2202892-1-hongliang.yang@cixtech.com?part=2

      reply	other threads:[~2026-11-17  3:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  2:17 [PATCH v9 0/2] Add CIX Sky1 USBSSP controller support Hongliang Yang
2026-11-17  2:17 ` [PATCH v9 1/2] dt-bindings: usb: Add CIX Sky1 USBSSP controller Hongliang Yang
2026-11-17  2:22   ` sashiko-bot
2026-11-17  2:17 ` [PATCH v9 2/2] usb: cdns3: Add CIX Sky1 glue driver Hongliang Yang
2026-11-17  3:15   ` sashiko-bot [this message]

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=sashiko-outbox-218132@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hongliang.yang@cixtech.com \
    --cc=linux-usb@vger.kernel.org \
    --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