mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/hpet: Use common error handling code in hpet_create_irq_domain()
@ 2026-06-09 11:42 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2026-06-09 11:42 UTC (permalink / raw)
  To: x86, Borislav Petkov, Daniel J Blueman, Dave Hansen,
	H. Peter Anvin, Ingo Molnar, Jiri Wiesner, Kees Cook,
	Thomas Gleixner
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 9 Jun 2026 13:28:18 +0200

Use additional labels so that a bit of exception handling can be better
reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/kernel/hpet.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 8dc7b710e125..ac7e06b40a16 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -553,30 +553,31 @@ static struct irq_domain *hpet_create_irq_domain(int hpet_id)
 
 	fn = irq_domain_alloc_named_id_fwnode(hpet_msi_controller.name,
 					      hpet_id);
-	if (!fn) {
-		kfree(domain_info);
-		return NULL;
-	}
+	if (!fn)
+		goto free_info;
 
 	fwspec.fwnode = fn;
 	fwspec.param_count = 1;
 	fwspec.param[0] = hpet_id;
 
 	parent = irq_find_matching_fwspec(&fwspec, DOMAIN_BUS_GENERIC_MSI);
-	if (!parent) {
-		irq_domain_free_fwnode(fn);
-		kfree(domain_info);
-		return NULL;
-	}
+	if (!parent)
+		goto free_fwnode;
+
 	if (parent != x86_vector_domain)
 		hpet_msi_controller.name = "IR-HPET-MSI";
 
 	d = msi_create_irq_domain(fn, domain_info, parent);
-	if (!d) {
-		irq_domain_free_fwnode(fn);
-		kfree(domain_info);
-	}
+	if (!d)
+		goto free_fwnode;
+
 	return d;
+
+free_fwnode:
+	irq_domain_free_fwnode(fn);
+free_info:
+	kfree(domain_info);
+	return NULL;
 }
 
 static inline int hpet_dev_id(struct irq_domain *domain)
-- 
2.54.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-09 11:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-09 11:42 [PATCH] x86/hpet: Use common error handling code in hpet_create_irq_domain() Markus Elfring

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