Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1467756ybh; Sun, 8 Mar 2020 05:09:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuH+p1SKMJcOPn3qNtPNpw0aOJvBOTvzQ5BkNRyUkWITVgNYmxBAy0S/uBfJKf8nc1gUqXk X-Received: by 2002:aca:b703:: with SMTP id h3mr8268881oif.148.1583669349199; Sun, 08 Mar 2020 05:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583669349; cv=none; d=google.com; s=arc-20160816; b=R2oj9OvwYCk+S1iAqfijUfmflswtKSyyD4dn8rLu5uXzZYos0MPpArWzA9VfboyBZG v8Qy1BdGiXCaShD2zJWy6mqZXKmabkRNf0LvYzwgsZmvnvaRyjNqT5ORmyLzMMWZspfF 6DZSJtV03WBV3U24IVTczXE7V9u2z7oi7e8Hua9/kWNDSV4hmM1b6oa5OYcoUIT0h59L Yw0iy9kxIEXn9xN4XQzCvtzNhJCqSSjvdWbuo53ZEXfB9PQ0iF+qbL2Oi3rrxiyXOndI wKnmVRTG5Pa9dtXP4X6iFggTO8yq5OfEQdri69Dwo0WpJf1guxyedaK+pUUAKpdFgEuH rQGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=I0muqG8U2BuqoCYrWbUxj3x1IF1/eIL2Y6IsAoG2pAU=; b=YZyrXLDgJRj73l52ilrJVpNYkWdFXoHUVhC/X8vwWDW0L3pqQoJrmSMSNTiywJDd1o qLpvnwqGQ1t5YvYZNfPzSaq0IGzH1NXo+4Vrn5NCpkmTemUtMfinn16NlC51u9lzjbqU P4hIdlFNK313KSLoS4OFbvIQwTwDCreHVH7FfskzyATePLDRDdalEJcS4fRgEELeLrR/ hS50eC6IZJmlTqM5C7A/fO71jpsn3FKltdeU6W7X2irOq2uTe/rvsSpZV9Gn9a3i5GMj 9Yhhr3l/Vt8VAkiwOyyb9/fdUfLLVbsHPV9i6+1A/76KRfObee/C9ABEU2JGAmKw/J1G QWrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si2859153ois.90.2020.03.08.05.08.56; Sun, 08 Mar 2020 05:09:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbgCHMHh (ORCPT + 99 others); Sun, 8 Mar 2020 08:07:37 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56562 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbgCHMHh (ORCPT ); Sun, 8 Mar 2020 08:07:37 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jAuiU-0005fZ-CX; Sun, 08 Mar 2020 13:07:34 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id B88711C220A; Sun, 8 Mar 2020 13:07:33 +0100 (CET) Date: Sun, 08 Mar 2020 12:07:33 -0000 From: "tip-bot2 for Alexander Sverdlin" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq/irqdomain: Check pointer in irq_domain_alloc_irqs_hierarchy() Cc: Alexander Sverdlin , Thomas Gleixner , x86 , LKML In-Reply-To: <20200306174720.82604-1-alexander.sverdlin@nokia.com> References: <20200306174720.82604-1-alexander.sverdlin@nokia.com> MIME-Version: 1.0 Message-ID: <158366925336.28353.5904197587974966508.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/core branch of tip: Commit-ID: 87f2d1c662fa1761359fdf558246f97e484d177a Gitweb: https://git.kernel.org/tip/87f2d1c662fa1761359fdf558246f97e484d177a Author: Alexander Sverdlin AuthorDate: Fri, 06 Mar 2020 18:47:20 +01:00 Committer: Thomas Gleixner CommitterDate: Sun, 08 Mar 2020 13:03:41 +01:00 genirq/irqdomain: Check pointer in irq_domain_alloc_irqs_hierarchy() irq_domain_alloc_irqs_hierarchy() has 3 call sites in the compilation unit but only one of them checks for the pointer which is being dereferenced inside the called function. Move the check into the function. This allows for catching the error instead of the following crash: Unable to handle kernel NULL pointer dereference at virtual address 00000000 PC is at 0x0 LR is at gpiochip_hierarchy_irq_domain_alloc+0x11f/0x140 ... [] (gpiochip_hierarchy_irq_domain_alloc) [] (__irq_domain_alloc_irqs) [] (irq_create_fwspec_mapping) [] (gpiochip_to_irq) [] (gpiod_to_irq) [] (gpio_irqs_init [gpio_irqs]) [] (gpio_irqs_exit+0xecc/0xe84 [gpio_irqs]) Code: bad PC value Signed-off-by: Alexander Sverdlin Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200306174720.82604-1-alexander.sverdlin@nokia.com --- kernel/irq/irqdomain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index fdfc213..35b8d97 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1310,6 +1310,11 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain, unsigned int irq_base, unsigned int nr_irqs, void *arg) { + if (!domain->ops->alloc) { + pr_debug("domain->ops->alloc() is NULL\n"); + return -ENOSYS; + } + return domain->ops->alloc(domain, irq_base, nr_irqs, arg); } @@ -1347,11 +1352,6 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, return -EINVAL; } - if (!domain->ops->alloc) { - pr_debug("domain->ops->alloc() is NULL\n"); - return -ENOSYS; - } - if (realloc && irq_base >= 0) { virq = irq_base; } else {