From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758714AbdHYUo6 (ORCPT ); Fri, 25 Aug 2017 16:44:58 -0400 Received: from terminus.zytor.com ([65.50.211.136]:35035 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755255AbdHYUo5 (ORCPT ); Fri, 25 Aug 2017 16:44:57 -0400 Date: Fri, 25 Aug 2017 13:43:39 -0700 From: tip-bot for Dan Carpenter Message-ID: Cc: mingo@kernel.org, dan.carpenter@oracle.com, linux-kernel@vger.kernel.org, marc.zyngier@arm.com, david.daney@cavium.com, hpa@zytor.com, tglx@linutronix.de Reply-To: linux-kernel@vger.kernel.org, david.daney@cavium.com, marc.zyngier@arm.com, mingo@kernel.org, dan.carpenter@oracle.com, tglx@linutronix.de, hpa@zytor.com In-Reply-To: <20170825121409.6rfv4vt6ztz2oqkt@mwanda> References: <20170825121409.6rfv4vt6ztz2oqkt@mwanda> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] irqdomain: Prevent potential NULL pointer dereference in irq_domain_push_irq() Git-Commit-ID: 20c4d49c0f304f3f945bbd560b26afa98f75a0c4 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: 20c4d49c0f304f3f945bbd560b26afa98f75a0c4 Gitweb: http://git.kernel.org/tip/20c4d49c0f304f3f945bbd560b26afa98f75a0c4 Author: Dan Carpenter AuthorDate: Fri, 25 Aug 2017 15:14:09 +0300 Committer: Thomas Gleixner CommitDate: Fri, 25 Aug 2017 22:40:26 +0200 irqdomain: Prevent potential NULL pointer dereference in irq_domain_push_irq() This code generates a Smatch warning: kernel/irq/irqdomain.c:1511 irq_domain_push_irq() warn: variable dereferenced before check 'root_irq_data' (see line 1508) irq_get_irq_data() can return a NULL pointer, but the code dereferences the returned pointer before checking it. Move the NULL pointer check before the dereference. [ tglx: Rewrote changelog to be precise and conforming to the instructions in submitting-patches and added a Fixes tag. Sigh! ] Fixes: 495c38d3001f ("irqdomain: Add irq_domain_{push,pop}_irq() functions") Signed-off-by: Dan Carpenter Signed-off-by: Thomas Gleixner Acked-by: David Daney Cc: Marc Zyngier Cc: kernel-janitors@vger.kernel.org Link: http://lkml.kernel.org/r/20170825121409.6rfv4vt6ztz2oqkt@mwanda --- kernel/irq/irqdomain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 1ff9912..d623517 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1504,10 +1504,10 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) if (WARN_ON(!irq_domain_is_hierarchy(domain))) return -EINVAL; - if (domain->parent != root_irq_data->domain) + if (!root_irq_data) return -EINVAL; - if (!root_irq_data) + if (domain->parent != root_irq_data->domain) return -EINVAL; child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL,