From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386967; b=XJD2/ou/8evLnhQlJakPlwRAHqRSkkAPTuyE0wDzmG+UJqT93beJWlJI+y9Ah57acVJM aX5Q2hdvfqyuSX+8cEAgPANN5OaC0mo0QRHp0YTjM5WviNVAx2DCfCgc8QJYVXWq0dpiR 2MGdx4BXndLAIvhS6ZnEZ5zqdevaE05AQGiWDcCKPfntDJfkD0N/BwkTo2Pov1CJ/VHms v2YMtAmKgtRCsnwB8JUX5yYHgg6TuA4GsdpH48l3or0iU4BKs2y//dT0MFY3vjg/WNMH8 oGJkUHI1nweSFmc3I6ZhqWtb2HMUnWzqmT0iqILM/uhHBIWWM6nmjT7Gd1/TgJbr4uQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386967; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=xwxzgwYd8FQ+RXTeJZaoAEby1R6x+Zsa9r8K2NM/JZM=; b=Mi6YhmBjD48AsdueX2fKPhPdjzTf65jiPuoiEWmQDvx0U3AchrkTvJYNP6nLNSPTIqE5 Q4xXqqDf1rqsMEI6OiFo/CASheAXgIvHDBQCm5GkEVCwlFbX0Kk2k0MLszz8iM5il7NQV WeOjGOpKBhAp1mFbIEqf2YqFzGymSuh4vSL0+pwctyFvUsNXFHHPLa1xKa7CDEk4fheYn TPg0I8x2nGSnRfeaWxYHVjPnt2LTYDcNrUfJx1yQqzh0zhBhSwqUXSEUmZlbY6m7cPr6k 19mL5Y2oqm3tTrJzT87aBAEeNSrQTxgiY1AiWsWfVPUs6kgod3z5VnyegTvAKSou8YA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qZ1cvkZV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30BA0606A322; Fri, 4 Dec 2026 12:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qZ1cvkZV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EBF31F00934; Fri, 4 Dec 2026 12:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386967; bh=xwxzgwYd8FQ+RXTeJZaoAEby1R6x+Zsa9r8K2NM/JZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qZ1cvkZV1jvZ11gdqetMWen4FMlzMzxLLeajpidzjdSzutUKlDT3O2Ct085jIDKym ror4Z9GuBRVqn9mpnnt4Z/w2ErH9kHw2fQ0GqgYTpjtAJsd8qGV+/qFjm78GSL3oRQ 11ZecE3fG4JM85wCeYgmAqmS03mVIVnYQwWDipd4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.1 0078/1059] gpio: mpc8xxx: Fix potential use-after-free of IRQ domain Date: Fri, 4 Dec 2026 18:53:29 +0900 Message-ID: <20261204100646.124927996@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li [ Upstream commit 9e4b35c95fede87bad36f68b7ff1eae94ea6b910 ] GPIO chip cleanup can call the to_irq callback while releasing requested GPIOs. Removing the IRQ domain first leaves that callback using a freed domain, both on removal and after an IRQ request failure. Register domain cleanup before GPIO chip registration so devres removes the chip before freeing the domain. This issue was found by our static analysis tool under development. Fixes: 257e10752c13 ("gpio: mpc8xxx: Use of_mm_gpiochip_remove") Signed-off-by: Guangshuo Li Link: https://patch.msgid.link/a4fec7fe970d6fc9135b488f57ba7e145b809359.1793377433.git.liguangshuo@mail.sdu.edu.cn Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-mpc8xxx.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index ae4815197184c..494770b7fae20 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -299,6 +299,14 @@ static const struct of_device_id mpc8xxx_gpio_ids[] = { {} }; +static void mpc8xxx_irq_domain_remove(void *data) +{ + struct mpc8xxx_gpio_chip *mpc8xxx_gc = data; + + if (mpc8xxx_gc->irq) + irq_domain_remove(mpc8xxx_gc->irq); +} + static int mpc8xxx_probe(struct platform_device *pdev) { const struct mpc8xxx_gpio_devtype *devtype = NULL; @@ -375,6 +383,11 @@ static int mpc8xxx_probe(struct platform_device *pdev) is_acpi_node(fwnode)) gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff); + /* GPIO chip cleanup still needs the IRQ domain. */ + ret = devm_add_action_or_reset(dev, mpc8xxx_irq_domain_remove, mpc8xxx_gc); + if (ret) + return ret; + ret = devm_gpiochip_add_data(dev, gc, mpc8xxx_gc); if (ret) { dev_err(dev, @@ -405,25 +418,20 @@ static int mpc8xxx_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "failed to devm_request_irq(%d), ret = %d\n", mpc8xxx_gc->irqn, ret); - goto err; + return ret; } device_init_wakeup(dev, true); return 0; -err: - irq_domain_remove(mpc8xxx_gc->irq); - return ret; } static void mpc8xxx_remove(struct platform_device *pdev) { struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev); - if (mpc8xxx_gc->irq) { + if (mpc8xxx_gc->irq) irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, NULL, NULL); - irq_domain_remove(mpc8xxx_gc->irq); - } } #ifdef CONFIG_PM -- 2.53.0