From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0693BC38A24 for ; Thu, 7 May 2020 15:08:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8B502083B for ; Thu, 7 May 2020 15:08:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IWqMyAMk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8B502083B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HCD8AzCcWdG00hnMAhdr68o8qNWBMHpPO4namWANBOY=; b=IWqMyAMkpYRHFj RbjrgqcPYe456a83CcwATtHO38cw57Ra1w3AIwupELT3512YgwpKsxSWSg5HGCCau4P4GMtpuViSR Imp4uEqf+Okl+pg8I+rsppOxJPIzXUh4xnRDejjgEoMfSlFx7BerkqoLO/c5SwV9X1GcuRHty+cKH D1FpPb8hOb1GQnxU2t0o2BxsBUlToaMGcB5OhzR0Wk+927dv6xquJctM9CUAh3iTKE08JyaljYilu +O9SEsy0GHYCFOpUcflabTgElxzi4AMiXAytbWwV3/2ArhHtNtbYwkQYSbmOiPc0BMkIcxsKVsTNv uxTHv2+rzVo7t9v/lAMA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWi8L-0004XG-EG; Thu, 07 May 2020 15:08:21 +0000 Received: from mail-out.m-online.net ([212.18.0.10]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWi7g-0004LQ-7q for linux-arm-kernel@lists.infradead.org; Thu, 07 May 2020 15:07:41 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49Hxf1571Lz1rtNH; Thu, 7 May 2020 17:07:37 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49Hxf14Lq0z1qtwM; Thu, 7 May 2020 17:07:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id aNUxGlV124a5; Thu, 7 May 2020 17:07:36 +0200 (CEST) X-Auth-Info: iWDVgyW8TVCuBeXnoCZ5Bm1lCGckYWQwVlFIl94Lnow= Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz [86.49.35.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 7 May 2020 17:07:36 +0200 (CEST) From: Marek Vasut To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] [RFC] genirq: Check irq_data_get_irq_chip() return value before use Date: Thu, 7 May 2020 17:07:29 +0200 Message-Id: <20200507150729.244468-1-marex@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200507_080740_424834_4B30C2F1 X-CRM114-Status: GOOD ( 12.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Marc Zyngier , Linus Walleij , Stephen Boyd , Thomas Gleixner Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org The irq_data_get_irq_chip() can return NULL. If the kernel accesses chip->irq_get_irqchip_state without checking whether chip is valid, we get a crash. Fix this by checking whether chip is not NULL before using it. Fixes: 1b7047edfcfb ("genirq: Allow the irqchip state of an IRQ to be save/restored") Signed-off-by: Marek Vasut Cc: Linus Walleij Cc: Marc Zyngier Cc: Stephen Boyd Cc: Thomas Gleixner To: linux-arm-kernel@lists.infradead.org --- NOTE: I don't know whether this is a correct fix. Maybe the irq_data_get_irq_chip() should never return NULL, and I have some other issue? --- kernel/irq/manage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index fe40c658f86f..509128ab21ea 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2663,7 +2663,7 @@ int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq_state which, do { chip = irq_data_get_irq_chip(data); - if (chip->irq_get_irqchip_state) + if (chip && chip->irq_get_irqchip_state) break; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY data = data->parent_data; @@ -2740,7 +2740,7 @@ int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, do { chip = irq_data_get_irq_chip(data); - if (chip->irq_set_irqchip_state) + if (chip && chip->irq_set_irqchip_state) break; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY data = data->parent_data; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel