Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4608C61DA4 for ; Thu, 23 Feb 2023 14:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234452AbjBWO7Y (ORCPT ); Thu, 23 Feb 2023 09:59:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234224AbjBWO7W (ORCPT ); Thu, 23 Feb 2023 09:59:22 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87FB718B29; Thu, 23 Feb 2023 06:59:19 -0800 (PST) Date: Thu, 23 Feb 2023 14:59:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1677164357; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jCVAjuc5AQRTS8zQItFvAnUhtNEEuOXdAGorfxjb+fo=; b=b7Kfw1JkDVa+jKCSPSm9R32gE/tCjArAehgQ+7IH5vjaV9ELcmPMlX67y/cqOLchB+I1an W8yPqtKZByDD6zsHHDPcBKkbKn++Ckn+NMnR6cjxQM+SWh65+QdFic7ij1VnZ248uo0oIM U+w6bG6u/4DA1hGGaaVGTdxQingN9GOzJkDalicwbXTmlLcIfZSINKXRlmTfRQTQDOPSfy 2IdtqWHeImi2ZK8TafEowN/P1RaTONYOTuHFTnBVMmJCahPkLgVlI/SN4OsavNviGE954i A5eDpGrLDhQjmyVwV73DVcm1Qd2g04wzuLOk+eHqSw6s4rDou0gJr/gSkyOKIg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1677164357; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jCVAjuc5AQRTS8zQItFvAnUhtNEEuOXdAGorfxjb+fo=; b=ASIIlfnEaq/9k1jpFPNjl0+JsgsEA1FtmvSHoLhbokQ28vXB04wghq/FrWMzQWObUbM821 g7kewmetgRItFmCQ== From: "tip-bot2 for Juergen Gross" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] irqdomain: Add missing NULL pointer check in irq_domain_create_hierarchy() Cc: Juergen Gross , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20230223083800.31347-1-jgross@suse.com> References: <20230223083800.31347-1-jgross@suse.com> MIME-Version: 1.0 Message-ID: <167716435690.5837.7282180286659633068.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/urgent branch of tip: Commit-ID: ad32ab9604f29827494024828f527228e84fbd2c Gitweb: https://git.kernel.org/tip/ad32ab9604f29827494024828f527228e84fbd2c Author: Juergen Gross AuthorDate: Thu, 23 Feb 2023 09:38:00 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 23 Feb 2023 15:52:28 +01:00 irqdomain: Add missing NULL pointer check in irq_domain_create_hierarchy() The recent switch to per-domain locking caused a NULL dereference in irq_domain_create_hierarchy(), as Xen code is calling msi_create_irq_domain() with a NULL parent pointer. Fix that by testing parent to be set before dereferencing it. For a non-existing parent the irqdomain's root will stay to point to itself. Fixes: 9dbb8e3452ab ("irqdomain: Switch to per-domain locking") Signed-off-by: Juergen Gross Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20230223083800.31347-1-jgross@suse.com --- kernel/irq/irqdomain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index aa5b7ee..6522dfb 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1172,7 +1172,8 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data); if (domain) { - domain->root = parent->root; + if (parent) + domain->root = parent->root; domain->parent = parent; domain->flags |= flags;