Re: [PATCH v6 5/8] gpiolib: cdev: don't leak the IRQ name when the chip is removed

From: Kent Gibson

Date: Wed Nov 18 2026 - 10:42:44 EST


On Mon, Nov 16, 2026 at 03:47:08PM +0200, Adrian Ambrozewicz wrote:
> The character device requests line IRQs with a copy of the consumer
> label as the name, and frees the name that free_irq() returns. When
> gpiochip_remove() frees the IRQ first, it drops that name and the copy
> leaks:
>
> unreferenced object (size 8):
> comm "gpio-hold"
> backtrace (crc dc8eac94):
> kstrdup
> kstrdup_and_replace
> edge_detector_setup
> linereq_create
> gpio_ioctl
>
> Keep the name with the line or v1 line event, and free it there,
> whoever freed the IRQ.
>
> Reproduced with gpio-sim: remove the chip under an open request with
> edge detection and a consumer label. kmemleak reports up to 23 such
> objects after 30 cycles; with this change, none after 100.
>

Reviewed-by: Kent Gibson <warthog618@xxxxxxxxx>

Cheers,
Kent.