Skip to contentSkip to conversation

irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling

PATCH In review Alexander Popov 3 participants 4 messages Jul 3, 2016 – Jul 11, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling

If an irq_domain is auto-recursive and irq_domain_alloc_irqs_recursive() for its parent has returned an error, then do return and avoid calling irq_domain_free_irqs_recursive() uselessly, because:
- if domain->ops->alloc() had failed for an auto-recursive irq_domain, then irq_domain_free_irqs_recursive() had already been called;
- if domain->ops->alloc() had failed for a not auto-recursive irq_domain, then there is nothing to free at all.

---
 kernel/irq/irqdomain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +4 -2
index 8798b6c..6458e34 100644
@@ -1144,8 +1144,10 @@ int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
 	if (recursive)
 		ret = irq_domain_alloc_irqs_recursive(parent, irq_base,
 						      nr_irqs, arg);
-	if (ret >= 0)
-		ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
+	if (ret < 0)
+		return ret;
+
+	ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
 	if (ret < 0 && recursive)
 		irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Alexander Popov

If an irq_domain is auto-recursive and irq_domain_alloc_irqs_recursive() for its parent has returned an error, then do return and avoid calling irq_domain_free_irqs_recursive() uselessly, because:
- if domain->ops->alloc() had failed for an auto-recursive irq_domain, then irq_domain_free_irqs_recursive() had already been called;
- if domain->ops->alloc() had failed for a not auto-recursive irq_domain, then there is nothing to free at all.

Hello.
Could I have a feedback, please?

Best regards,
Alexander

Quoted 23 lines
---
 kernel/irq/irqdomain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +4 -2
index 8798b6c..6458e34 100644
@@ -1144,8 +1144,10 @@ int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
 	if (recursive)
 		ret = irq_domain_alloc_irqs_recursive(parent, irq_base,
 						      nr_irqs, arg);
-	if (ret >= 0)
-		ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
+	if (ret < 0)
+		return ret;
+
+	ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
 	if (ret < 0 && recursive)
 		irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);
 
Acked-by on v1 1/1
#2 lore raw
In reply to Alexander Popov
Quoted 21 lines · Alexander Popov

If an irq_domain is auto-recursive and irq_domain_alloc_irqs_recursive() for its parent has returned an error, then do return and avoid calling irq_domain_free_irqs_recursive() uselessly, because:
- if domain->ops->alloc() had failed for an auto-recursive irq_domain, then irq_domain_free_irqs_recursive() had already been called;
- if domain->ops->alloc() had failed for a not auto-recursive irq_domain, then there is nothing to free at all.

---
 kernel/irq/irqdomain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +0 -0
index 8798b6c..6458e34 100644
@@ -1144,8 +1144,10 @@ int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
 	if (recursive)
 		ret = irq_domain_alloc_irqs_recursive(parent, irq_base,

kernel/irq/irqdomain.c int irq_domain_alloc_irqs_recursive(struct irq_domain *domain, · line 1153

Quoted 10 lines
kernel/irq/irqdomain.c +4 -2
 						      nr_irqs, arg);
-	if (ret >= 0)
-		ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
+	if (ret < 0)
+		return ret;
+
+	ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
 	if (ret < 0 && recursive)
 		irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);
 
	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#3 lore raw
In reply to Alexander Popov
irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling
Commit-ID:  a1b7b1a57b9919a0abb6c93fca04ac9cf840c992
Gitweb:     http://git.kernel.org/tip/a1b7b1a57b9919a0abb6c93fca04ac9cf840c992
Author:     Alexander Popov <[email protected]>
AuthorDate: Sun, 3 Jul 2016 03:24:08 +0300
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 11 Jul 2016 17:23:48 +0200

irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling

If an irq_domain is auto-recursive and irq_domain_alloc_irqs_recursive() for its parent has returned an error, then do return and avoid calling irq_domain_free_irqs_recursive() uselessly, because:
- if domain->ops->alloc() had failed for an auto-recursive irq_domain, then irq_domain_free_irqs_recursive() had already been called;
- if domain->ops->alloc() had failed for a not auto-recursive irq_domain, then there is nothing to free at all.

---
 kernel/irq/irqdomain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +4 -2
index a828537..4752b43 100644
@@ -1192,8 +1192,10 @@ int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
 	if (recursive)
 		ret = irq_domain_alloc_irqs_recursive(parent, irq_base,
 						      nr_irqs, arg);
-	if (ret >= 0)
-		ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
+	if (ret < 0)
+		return ret;
+
+	ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
 	if (ret < 0 && recursive)
 		irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);