All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling
@ 2016-07-03  0:24 Alexander Popov
  2016-07-11 11:53 ` Alexander Popov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Popov @ 2016-07-03  0:24 UTC (permalink / raw)
  To: Jiang Liu, Marc Zyngier, Thomas Gleixner, linux-kernel,
	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.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
---
 kernel/irq/irqdomain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 8798b6c..6458e34 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -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);
 
-- 
1.9.1

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

* Re: [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling
  2016-07-03  0:24 [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling Alexander Popov
@ 2016-07-11 11:53 ` Alexander Popov
  2016-07-11 15:18 ` Marc Zyngier
  2016-07-11 15:27 ` [tip:irq/core] " tip-bot for Alexander Popov
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Popov @ 2016-07-11 11:53 UTC (permalink / raw)
  To: Marc Zyngier, Thomas Gleixner, linux-kernel, Alexander Popov

On 03.07.2016 03:24, Alexander Popov wrote:
> 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

> Signed-off-by: Alexander Popov <alex.popov@linux.com>
> ---
>  kernel/irq/irqdomain.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 8798b6c..6458e34 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -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);
>  
> 

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

* Re: [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling
  2016-07-03  0:24 [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling Alexander Popov
  2016-07-11 11:53 ` Alexander Popov
@ 2016-07-11 15:18 ` Marc Zyngier
  2016-07-11 15:27 ` [tip:irq/core] " tip-bot for Alexander Popov
  2 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2016-07-11 15:18 UTC (permalink / raw)
  To: Alexander Popov, Jiang Liu, Thomas Gleixner, linux-kernel

On 03/07/16 01:24, Alexander Popov wrote:
> 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.
> 
> Signed-off-by: Alexander Popov <alex.popov@linux.com>
> ---
>  kernel/irq/irqdomain.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 8798b6c..6458e34 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -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: Marc Zyngier <marc.zyngier@arm.com>

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [tip:irq/core] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling
  2016-07-03  0:24 [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling Alexander Popov
  2016-07-11 11:53 ` Alexander Popov
  2016-07-11 15:18 ` Marc Zyngier
@ 2016-07-11 15:27 ` tip-bot for Alexander Popov
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Alexander Popov @ 2016-07-11 15:27 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, hpa, alex.popov, marc.zyngier, tglx, linux-kernel

Commit-ID:  a1b7b1a57b9919a0abb6c93fca04ac9cf840c992
Gitweb:     http://git.kernel.org/tip/a1b7b1a57b9919a0abb6c93fca04ac9cf840c992
Author:     Alexander Popov <alex.popov@linux.com>
AuthorDate: Sun, 3 Jul 2016 03:24:08 +0300
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Link: http://lkml.kernel.org/r/1467505448-2850-1-git-send-email-alex.popov@linux.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/irq/irqdomain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index a828537..4752b43 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -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);
 

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

end of thread, other threads:[~2016-07-11 15:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-03  0:24 [PATCH 1/1] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling Alexander Popov
2016-07-11 11:53 ` Alexander Popov
2016-07-11 15:18 ` Marc Zyngier
2016-07-11 15:27 ` [tip:irq/core] " tip-bot for Alexander Popov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.