Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ryan Roberts" <ryan.roberts@arm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	robh@kernel.org, conor+dt@kernel.org,
	"Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [RFC PATCH v2 04/15] misc/arm-cla: Probe firmware-described devices
Date: Thu, 15 Oct 2026 14:37:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-172966@kernel.org> (raw)
In-Reply-To: <20261015142552.4128028-5-ryan.roberts@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] core: mixed goto-based error handling and scoped_guard in cla_module_init()
--

commit 0ee32d948034264a0bab6422d831ac58dbde58cd
Author: Jean-Philippe Brucker <jpb@kernel.org>

misc/arm-cla: Probe firmware-described devices

This commit discovers and instantiates CLA devices described by firmware 
using platform_driver_probe. It also adds topology grouping for domains and 
registers CPU hotplug callbacks to manage hardware setup per CLA-local CPU.

> diff --git a/drivers/misc/arm-cla/cla-init.c b/drivers/misc/arm-cla/cla-init.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/misc/arm-cla/cla-init.c
[ ... ]
> +static int __init cla_module_init(void)
> +{
> +	bool driver_registered = false;
> +	int ret;
> +
> +	/*
> +	 * For now, we reject any CLAs discovered via FW tables, whose CPU is
> +	 * offline during init. This keeps things simple by allowing us to probe
> +	 * all HW at init time. Keep the online CPU set stable so that the
> +	 * cpu_online() check in cla_probe() is consistent with the online cpus
> +	 * when we call cpuhp_setup_state().
> +	 */
> +	scoped_guard(cpus_read_lock) {
> +		/*
> +		 * CPUs may be hotplugged, but all CLAs are described by
> +		 * firmware so the probe can be synchronous. This only sets up
> +		 * the resources, and CPUHP callbacks do the actual peeking and
> +		 * poking. This returns an error when no CLA has an online CPU.
> +		 */
> +		ret = platform_driver_probe(&cla_driver, cla_probe);
> +		if (ret) {
> +			if (ret != -ENODEV)
> +				pr_err("arm-cla: probe failed with %d\n", ret);
> +			/* Some domains may have been created during probe. */
> +			goto err_hardware;

[Severity: Medium]
The function cla_module_init() uses a scoped_guard(cpus_read_lock) block while
also jumping to a manual err_hardware cleanup label.

According to the cleanup and guard subsystem guidelines in
include/linux/cleanup.h, mixing goto-based error handling with scope-based
cleanups in the same function is considered an anti-pattern. This creates
confusing ownership semantics and risks double-frees or resource leaks during
future refactoring. 

Could this function be refactored to consistently use either only scope-based
cleanup or only goto-based error handling?

> +		}
[ ... ]
> +
> +err_hardware:
> +	if (cla_cpuhp_state >= 0)
> +		cpuhp_remove_state(cla_cpuhp_state);
> +	cla_domains_free();
> +	if (driver_registered)
> +		platform_driver_unregister(&cla_driver);
> +	return ret;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015142552.4128028-1-ryan.roberts@arm.com?part=4

  reply	other threads:[~2026-10-15 14:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 14:25 [RFC PATCH v2 00/15] Arm Core Local Accelerator Driver Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 01/15] misc/arm-cla: Add driver skeleton and documentation Ryan Roberts
2026-10-15 14:35   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 02/15] misc/arm-cla: Add launch operation helpers Ryan Roberts
2026-10-15 14:42   ` sashiko-bot
2026-10-15 16:17   ` Greg Kroah-Hartman
2026-10-15 16:32     ` Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 03/15] dt-bindings: misc: Add Arm Core Local Accelerator Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 04/15] misc/arm-cla: Probe firmware-described devices Ryan Roberts
2026-10-15 14:37   ` sashiko-bot [this message]
2026-10-15 14:25 ` [RFC PATCH v2 05/15] misc/arm-cla: Initialize devices on CPU bringup Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 06/15] misc/arm-cla: Accelerator context save and restore Ryan Roberts
2026-10-15 14:41   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 07/15] misc/arm-cla: Set up memory translation context Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 08/15] misc/arm-cla: Manage domain contexts Ryan Roberts
2026-10-15 14:38   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 09/15] misc/arm-cla: Add userspace interface Ryan Roberts
2026-10-15 14:47   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 10/15] KVM: arm64: Introduce support to pin VMIDs Ryan Roberts
2026-10-15 14:38   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 11/15] KVM: arm64: Export stage-2 MMU config Ryan Roberts
2026-10-15 14:43   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 12/15] vfio: Support VFIO devices that access the CPU MMU Ryan Roberts
2026-10-15 14:44   ` sashiko-bot
2026-10-15 16:44   ` Jason Gunthorpe
2026-10-15 14:25 ` [RFC PATCH v2 13/15] misc/arm-cla: Add stage-2 MTC and VM context switch Ryan Roberts
2026-10-15 14:40   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 14/15] misc/arm-cla: Support exclusive context assignment Ryan Roberts
2026-10-15 14:41   ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 15/15] misc/arm-cla: Add vfio-mdev user interface Ryan Roberts
2026-10-15 14:49   ` sashiko-bot
2026-10-15 16:41   ` Jason Gunthorpe

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-172966@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=robh@kernel.org \
    --cc=ryan.roberts@arm.com \
    --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