From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759398AbcGKP16 (ORCPT ); Mon, 11 Jul 2016 11:27:58 -0400 Received: from terminus.zytor.com ([198.137.202.10]:49194 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754867AbcGKP14 (ORCPT ); Mon, 11 Jul 2016 11:27:56 -0400 Date: Mon, 11 Jul 2016 08:27:45 -0700 From: tip-bot for Alexander Popov Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, alex.popov@linux.com, marc.zyngier@arm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, marc.zyngier@arm.com, alex.popov@linux.com, hpa@zytor.com, mingo@kernel.org In-Reply-To: <1467505448-2850-1-git-send-email-alex.popov@linux.com> References: <1467505448-2850-1-git-send-email-alex.popov@linux.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] irqdomain: Fix irq_domain_alloc_irqs_recursive() error handling Git-Commit-ID: a1b7b1a57b9919a0abb6c93fca04ac9cf840c992 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a1b7b1a57b9919a0abb6c93fca04ac9cf840c992 Gitweb: http://git.kernel.org/tip/a1b7b1a57b9919a0abb6c93fca04ac9cf840c992 Author: Alexander Popov AuthorDate: Sun, 3 Jul 2016 03:24:08 +0300 Committer: Thomas Gleixner 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 Acked-by: Marc Zyngier Link: http://lkml.kernel.org/r/1467505448-2850-1-git-send-email-alex.popov@linux.com Signed-off-by: Thomas Gleixner --- 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);