The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Yuho Choi <dbgh9129@gmail.com>
To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
	Yicong Yang <yangyicong@hisilicon.com>,
	Oliver Upton <oupton@kernel.org>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] arm64: cpuinfo: Fix sysfs cleanup on failure
Date: Thu,  2 Jul 2026 19:07:44 -0400	[thread overview]
Message-ID: <20260702230744.91169-1-dbgh9129@gmail.com> (raw)

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


                 reply	other threads:[~2026-07-02 23:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260702230744.91169-1-dbgh9129@gmail.com \
    --to=dbgh9129@gmail.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oupton@kernel.org \
    --cc=wangzhou1@hisilicon.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox