mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: "Lee Jones" <lee@kernel.org>, "Linus Walleij" <linusw@kernel.org>,
	"Uwe Kleine-König (The Capable Hub)"
	<u.kleine-koenig@baylibre.com>,
	"Gregory Bean" <gbean@codeaurora.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 12/12] pinctrl: sx150x: Register threaded IRQ after adding GPIO chip
Date: Wed, 2 Dec 2026 10:35:05 +0100	[thread overview]
Message-ID: <397c3307-0e6c-426c-b2a0-044f6fee169a@linaro.org> (raw)
In-Reply-To: <8870b35b8eb43112b7aa44e401ec92970520178e.1796203691.git.lee@kernel.org>

On 12/2/26 10:30, Lee Jones wrote:
> sx150x_probe() calls devm_request_threaded_irq() with IRQF_SHARED before
> devm_gpiochip_add_data().  If a shared or pending interrupt fires before
> the GPIO chip is registered, sx150x_irq_thread_fn() passes a NULL
> pctl->gpio.irq.domain to irq_find_mapping().  Because devres tears down
> resources in LIFO order, this ordering also removes the GPIO chip and
> its IRQ domain while the threaded IRQ handler is still active during
> probe failure or device unbind, causing a use-after-free.
> 
> Move devm_request_threaded_irq() after devm_gpiochip_add_data() so the
> IRQ domain is created before the handler can run and torn down after the
> IRQ is freed.
> 
> Fixes: 0a04d767af8c ("pinctrl: sx150x: Use irqchip template")
> Closes: https://sashiko.dev/#/bug/linux-a189ae4f-4985-46ad-acce-6092c69d60e0
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>   drivers/pinctrl/pinctrl-sx150x.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
> index 0cf68fe22f89..bbc8c4f1f44a 100644
> --- a/drivers/pinctrl/pinctrl-sx150x.c
> +++ b/drivers/pinctrl/pinctrl-sx150x.c
> @@ -1164,7 +1164,7 @@ static int sx150x_probe(struct i2c_client *client)
>   				     I2C_FUNC_SMBUS_WRITE_WORD_DATA;
>   	struct device *dev = &client->dev;
>   	struct sx150x_pinctrl *pctl;
> -	u32 irq_type;
> +	u32 irq_type = 0;
>   	int ret;
>   
>   	if (!i2c_check_functionality(client->adapter, i2c_funcs))
> @@ -1288,7 +1288,13 @@ static int sx150x_probe(struct i2c_client *client)
>   					"unsupported irq trigger type %x\n",
>   					irq_type);
>   		}
> +	}
>   
> +	ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
> +	if (ret)
> +		return ret;
> +
> +	if (client->irq > 0) {
>   		ret = devm_request_threaded_irq(dev, client->irq, NULL,
>   						sx150x_irq_thread_fn,
>   						IRQF_ONESHOT | IRQF_SHARED |
> @@ -1298,10 +1304,6 @@ static int sx150x_probe(struct i2c_client *client)
>   			return ret;
>   	}
>   
> -	ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
> -	if (ret)
> -		return ret;
> -
>   	/*
>   	 * Pin control functions need to be enabled AFTER registering the
>   	 * GPIO chip because sx150x_pinconf_set() calls

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

      reply	other threads:[~2026-12-02  9:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:29 [PATCH 00/12] pinctrl: Fix Critical and High issues reported by Sashiko (batch 3) Lee Jones
2026-12-02  9:29 ` [PATCH 01/12] pinctrl: stm32: Validate npins against STM32_GPIO_PINS_PER_BANK Lee Jones
2026-12-02  9:29 ` [PATCH 02/12] pinctrl: imx: Validate pin_id in imx_pinctrl_parse_pin_mmio() Lee Jones
2026-12-02  9:29 ` [PATCH 03/12] pinctrl: single: Protect group and function updates with pctldev->mutex Lee Jones
2026-12-02 14:08   ` Bartosz Golaszewski
2026-12-02  9:29 ` [PATCH 04/12] pinctrl: imx: Propagate DT parsing errors in imx_pinctrl_probe_dt() Lee Jones
2026-12-02  9:29 ` [PATCH 05/12] pinctrl: tegra: Require at least one register bank in tegra_pinctrl_probe() Lee Jones
2026-12-02  9:30 ` [PATCH 06/12] pinctrl: imx: Serialise MMIO register updates with a spinlock Lee Jones
2026-12-02  9:30 ` [PATCH 07/12] pinctrl: nuvoton: ma35: Avoid double free of shared pin configs Lee Jones
2026-12-02  9:30 ` [PATCH 08/12] pinctrl: keembay: Check src before calling keembay_find_free_slot() Lee Jones
2026-12-02  9:30 ` [PATCH 09/12] pinctrl: ti: iodelay: Protect generic group addition with pctldev->mutex Lee Jones
2026-12-02  9:30 ` [PATCH 10/12] pinctrl: sunxi: Serialise per-bank regulator request and free Lee Jones
2026-12-02  9:30 ` [PATCH 11/12] pinctrl: stm32: Protect irqmux restore with hwspinlock during resume Lee Jones
2026-12-02  9:30 ` [PATCH 12/12] pinctrl: sx150x: Register threaded IRQ after adding GPIO chip Lee Jones
2026-12-02  9:35   ` Neil Armstrong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=397c3307-0e6c-426c-b2a0-044f6fee169a@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=gbean@codeaurora.org \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®