mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] arm64: cpuinfo: Fix sysfs cleanup on failure
@ 2026-07-02 23:07 Yuho Choi
  2026-07-16 12:18 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Yuho Choi @ 2026-07-02 23:07 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Mark Brown, Yicong Yang, Oliver Upton, Zhou Wang,
	linux-arm-kernel, linux-kernel, Yuho Choi

cpuid_cpu_online() creates the CPU registers kobject and the base
identification attribute group before optionally merging the SME-specific
SMIDR attribute into that group.

If the base group creation fails, return after deleting the kobject. If
the SME merge fails, remove the base group before deleting the kobject.

Fixes: d69d56496487 ("arm64/sme: Expose SMIDR through sysfs")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 arch/arm64/kernel/cpuinfo.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index d50e2a9b066b..141bcfa4d611 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -380,9 +380,19 @@ static int cpuid_cpu_online(unsigned int cpu)
 		goto out;
 	rc = sysfs_create_group(&info->kobj, &cpuregs_attr_group);
 	if (rc)
-		kobject_del(&info->kobj);
-	if (system_supports_sme())
+		goto out_del_kobj;
+	if (system_supports_sme()) {
 		rc = sysfs_merge_group(&info->kobj, &sme_cpuregs_attr_group);
+		if (rc)
+			goto out_remove_group;
+	}
+
+	return 0;
+
+out_remove_group:
+	sysfs_remove_group(&info->kobj, &cpuregs_attr_group);
+out_del_kobj:
+	kobject_del(&info->kobj);
 out:
 	return rc;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] arm64: cpuinfo: Fix sysfs cleanup on failure
  2026-07-02 23:07 [PATCH v1] arm64: cpuinfo: Fix sysfs cleanup on failure Yuho Choi
@ 2026-07-16 12:18 ` Will Deacon
  2026-07-17 14:45   ` 최유호
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2026-07-16 12:18 UTC (permalink / raw)
  To: Yuho Choi
  Cc: Catalin Marinas, Mark Brown, Yicong Yang, Oliver Upton,
	Zhou Wang, linux-arm-kernel, linux-kernel

On Thu, Jul 02, 2026 at 07:07:44PM -0400, Yuho Choi wrote:
> cpuid_cpu_online() creates the CPU registers kobject and the base
> identification attribute group before optionally merging the SME-specific
> SMIDR attribute into that group.
> 
> If the base group creation fails, return after deleting the kobject. If
> the SME merge fails, remove the base group before deleting the kobject.

Why is it a good idea to remove the entire group if the merge fails?
Wouldn't it be more pragmatic to continue with the group that we did
manage to create? I don't really get why this proposed behaviour is
better.

Will

> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index d50e2a9b066b..141bcfa4d611 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -380,9 +380,19 @@ static int cpuid_cpu_online(unsigned int cpu)
>  		goto out;
>  	rc = sysfs_create_group(&info->kobj, &cpuregs_attr_group);
>  	if (rc)
> -		kobject_del(&info->kobj);
> -	if (system_supports_sme())
> +		goto out_del_kobj;
> +	if (system_supports_sme()) {
>  		rc = sysfs_merge_group(&info->kobj, &sme_cpuregs_attr_group);
> +		if (rc)
> +			goto out_remove_group;
> +	}
> +
> +	return 0;
> +
> +out_remove_group:
> +	sysfs_remove_group(&info->kobj, &cpuregs_attr_group);
> +out_del_kobj:
> +	kobject_del(&info->kobj);
>  out:
>  	return rc;
>  }
> -- 
> 2.43.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] arm64: cpuinfo: Fix sysfs cleanup on failure
  2026-07-16 12:18 ` Will Deacon
@ 2026-07-17 14:45   ` 최유호
  0 siblings, 0 replies; 3+ messages in thread
From: 최유호 @ 2026-07-17 14:45 UTC (permalink / raw)
  To: Will Deacon
  Cc: Catalin Marinas, Mark Brown, Yicong Yang, Oliver Upton,
	Zhou Wang, linux-arm-kernel, linux-kernel

On Thu, 16 Jul 2026 at 08:18, Will Deacon <will@kernel.org> wrote:
>
> Why is it a good idea to remove the entire group if the merge fails?
> Wouldn't it be more pragmatic to continue with the group that we did
> manage to create? I don't really get why this proposed behaviour is
> better.

You're right. Removing the entire group on an SME merge failure is
unncessary. I'll send a v2 incorporating your suggestion.

Thanks for your time reviewing.

Yuho.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-17 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-02 23:07 [PATCH v1] arm64: cpuinfo: Fix sysfs cleanup on failure Yuho Choi
2026-07-16 12:18 ` Will Deacon
2026-07-17 14:45   ` 최유호

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox