Re: [PATCH] gpio: virtuser: skip free_irq when no IRQ is installed

From: Linus Walleij

Date: Mon Sep 14 2026 - 04:01:32 EST


On Mon, Sep 14, 2026 at 7:15 AM Runyu Xiao <runyu.xiao@xxxxxxxxxx> wrote:

> Disabling interrupt monitoring uses atomic_xchg() to clear the stored IRQ.
> When monitoring is already disabled, atomic_xchg() returns 0. It must not
> be passed to free_irq().
>
> The bug is reproducible on an x86_64 QEMU guest with
> CONFIG_GPIO_VIRTUSER=y and CONFIG_GPIO_SIM=y. Configure a live
> gpio-virtuser device through configfs. Its input lookup must refer to a
> live gpio-sim bank, such as key gpio-sim-test with offset 0. The
> consumer's dev_name attribute is shown as <dev> below; then run:
>
> echo 0 > /sys/kernel/debug/gpio-virtuser/<dev>/gpiod:input:0/interrupts
>
> On an unpatched kernel, this reaches gpio_virtuser_interrupts_set() with
> ld->irq still at its initial value 0, and free_irq() reports:
>
> Trying to free already-free IRQ 0
>
> The same reproducer completes without the warning on the patched kernel.
>
> Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GPIO API")
> Assisted-by: LLM Codex

This should just sat Assisted-by: LLM but Bartosz can fix that when applying
I think.

> Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>

Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Yours,
Linus Walleij