Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9110609pxu; Mon, 28 Dec 2020 06:55:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUJRxgcRmTRxvV7yPykRa2/sfpvZdwo8f8FkHZG+HyvDR6YRGgUIzcYGMeX+LjS+xIaMxw X-Received: by 2002:a17:907:41e3:: with SMTP id nb3mr42613823ejb.378.1609167327744; Mon, 28 Dec 2020 06:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167327; cv=none; d=google.com; s=arc-20160816; b=R7W2PFjoTUZc1CFMVnvZ6o43al45EZljmJVZC3X1TAtxMHIt7IsWRhisJf23lnyMSf 06u1ZLoos/PLSmFmyPno1sbByigp1WBGyVUQPOPauc3MG6rBGQ/TQ23TA188JEUwZ1hT 2s9VlNa5jMwaCy98w362AyTC1jjpYXObJub2VeNjAn5fQoszIHs48iOxxaCvPvTBuBBY 9K3FUaer5YrC5aSGzZrfSW2jMyKXvDBhe3w0r9ukocRra9g3rEfOBlpaJdBOo3EHgrw+ /sHinZyfcFNgv9LauFXTBlGVqZaBB8FybfGworUv4bSzxHxixB145wylvz/SM1hze1xr eeSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cGMLdBQuiv82kRTstFZ4F9zq/3PHgVhplb2q1RzVLDI=; b=X3InETLXlIRhPjlyMYTNWUDBMH6hyTTn6BaAf1f8jU5gUS93FSrt5QUPvKj6C3Yu8r nU0eJuhQC/VOxJFCN9tZlMjRTrqS5IdrG1qZFDNN+avVJujgLXvXYBKiKY0X/2ENGfg4 t+XuJWByYIbBwK5CmJBgWGeTHlx2cWMt+7oCV2td0Awlw5FoSqdRRefp1eFJGgEcgO9Y ZsNLOkifsMb5LQXAamDIUbNDTee+XASKA431KV1yDQc+WKyISSr9l52XEBwaD35xIbPt wiisp/t4o84hUBxc7nBY83JIInzx0cuB2Vcvn83jXtcMCPCwLx7sXxuzrwNHbpnFQR91 OCtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SdwNaWXA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si18981697ejr.727.2020.12.28.06.55.03; Mon, 28 Dec 2020 06:55:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SdwNaWXA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502125AbgL1OTi (ORCPT + 99 others); Mon, 28 Dec 2020 09:19:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:54902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502107AbgL1OTg (ORCPT ); Mon, 28 Dec 2020 09:19:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D010206D4; Mon, 28 Dec 2020 14:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165136; bh=yc0hZNOKlgsQGCmuGr8ozOHMQXfNzGnkzwNI4C/Z3u8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SdwNaWXAYSKN5J78uzaDbT/eFti07rrfaGQxINmI1uDLMDZlj2IY9pY1ThqFAvJOp inLMKxH0ACVrb/aIXMpXT1cyz+FAjVLyXrioWJTqp/K1tlQEifDqWpeetH57r9O9vL e3TI3TgFnwnfDIYCf5vj5S6Yzo1Xis0Wmdy/YRWQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikita Shubin , Linus Walleij , Sasha Levin Subject: [PATCH 5.10 425/717] gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask Date: Mon, 28 Dec 2020 13:47:03 +0100 Message-Id: <20201228125041.326234535@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikita Shubin [ Upstream commit 9d5522199505c761575c8ea31dcfd9a2a8d73614 ] irqchip shared with multiple gpiochips, leads to recursive call of gpiochip_irq_mask/gpiochip_irq_unmask which was assigned to rqchip->irq_mask/irqchip->irq_unmask, these happens becouse of only irqchip->irq_enable == gpiochip_irq_enable is checked. Let's add an additional check to make sure shared irqchip is detected even if irqchip->irq_enable wasn't defined. Fixes: a8173820f441 ("gpio: gpiolib: Allow GPIO IRQs to lazy disable") Signed-off-by: Nikita Shubin Link: https://lore.kernel.org/r/20201210070514.13238-1-nikita.shubin@maquefel.me Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 6e3c4d7a7d146..4ad3c4b276dcf 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1477,7 +1477,8 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc) if (WARN_ON(gc->irq.irq_enable)) return; /* Check if the irqchip already has this hook... */ - if (irqchip->irq_enable == gpiochip_irq_enable) { + if (irqchip->irq_enable == gpiochip_irq_enable || + irqchip->irq_mask == gpiochip_irq_mask) { /* * ...and if so, give a gentle warning that this is bad * practice. -- 2.27.0