[PATCH RESEND] irqchip/partitions: Fix exception handling in partition_create_desc()

From: Markus Elfring
Date: Tue Mar 04 2025 - 15:06:34 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Mar 2023 21:38:47 +0100

The label “out” was used to jump to another pointer check despite of
the detail in the implementation of the function “partition_create_desc”
that it was determined already that a corresponding variable contained
still a null pointer.

* Thus use more appropriate labels instead.

* Delete a redundant check.


This issue was detected by using the Coccinelle software.

Fixes: 9e2c986cb460 ("irqchip: Add per-cpu interrupt partitioning library")
Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/irqchip/irq-partition-percpu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-partition-percpu.c b/drivers/irqchip/irq-partition-percpu.c
index 8e76d2913e6b..80e1c73af87e 100644
--- a/drivers/irqchip/irq-partition-percpu.c
+++ b/drivers/irqchip/irq-partition-percpu.c
@@ -212,21 +212,21 @@ struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode,

d = irq_domain_create_linear(fwnode, nr_parts, &desc->ops, desc);
if (!d)
- goto out;
+ goto free_desc;
desc->domain = d;

desc->bitmap = bitmap_zalloc(nr_parts, GFP_KERNEL);
if (WARN_ON(!desc->bitmap))
- goto out;
+ goto remove_domain;

desc->chained_desc = irq_to_desc(chained_irq);
desc->nr_parts = nr_parts;
desc->parts = parts;

return desc;
-out:
- if (d)
- irq_domain_remove(d);
+remove_domain:
+ irq_domain_remove(d);
+free_desc:
kfree(desc);

return NULL;
--
2.40.0