Re: [PATCH] gpib: ines: Fix resource leak in ines_isa_attach()

From: Dominik Karol Piątkowski

Date: Thu May 28 2026 - 13:05:04 EST


Hi Hongling Zeng,

On Thursday, May 28th, 2026 at 04:03, Hongling Zeng <zenghongling@xxxxxxxxxx> wrote:

> When request_irq() fails in ines_isa_attach(), the function returns -1
> without releasing the I/O port region that was successfully acquired
> earlier by request_region(). This causes a resource leak.
>
> Fix this by adding a proper error path that releases the I/O port
> region before returning.
>
> Fixes: 0de51244e7b7e3 ("gpib: ines: use request_region for isa devices")
> Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> drivers/gpib/ines/ines_gpib.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpib/ines/ines_gpib.c b/drivers/gpib/ines/ines_gpib.c
> index c000f647fbb5..1e5112d05dfc 100644
> --- a/drivers/gpib/ines/ines_gpib.c
> +++ b/drivers/gpib/ines/ines_gpib.c
> @@ -911,11 +911,16 @@ static int ines_isa_attach(struct gpib_board *board, const struct gpib_board_con
> nec7210_board_reset(nec_priv, board);
> if (request_irq(config->ibirq, ines_pci_interrupt, isr_flags, DRV_NAME, board)) {
> dev_err(board->gpib_dev, "failed to allocate IRQ %d\n", config->ibirq);
> - return -1;
> + retval = -ENODEV;
> + goto err_release_region;
> }
> ines_priv->irq = config->ibirq;
> ines_online(ines_priv, board, 1);
> return 0;
> +
> +err_release_region:
> + release_region(config->ibbase, ines_isa_iosize);
> + return retval;

I see a similar problem to what I've found in fmh_gpib patch:
https://lore.kernel.org/all/LpJShJPaUZ8iZoWRA7Sy9TPz_7ZPHNvoU0lHOBrVEXvQGqlz493ShbF6ZKQ2zcRqPHVuxOkjzR0KCdS6OngnflPYa0gsqaRTpRWFbxuqQ4A=@protonmail.com/

Thanks,
Dominik Karol

> }
>
> static void ines_pci_detach(struct gpib_board *board)
> --
> 2.25.1
>
>