Re: [PATCH v2] gpib: cb7210: Fix region leak when request_irq fails

From: Dominik Karol Piątkowski

Date: Thu May 28 2026 - 13:52:48 EST


Hi,

This patch is already in linux-next, but I see a problem similar to what I've
found here:

https://lore.kernel.org/all/LpJShJPaUZ8iZoWRA7Sy9TPz_7ZPHNvoU0lHOBrVEXvQGqlz493ShbF6ZKQ2zcRqPHVuxOkjzR0KCdS6OngnflPYa0gsqaRTpRWFbxuqQ4A=@protonmail.com/

Additionally, we're releasing the region we never obtained.
I believe this patch should be reverted.

Thanks,
Dominik Karol

On Monday, May 18th, 2026 at 04:29, Hongling Zeng <zenghongling@xxxxxxxxxx> wrote:

> When request_irq() fails, the region allocated by request_region()
> is not released. Fix this by adding an error handling path with
> proper goto labels to release the region.
>
> Fixes: e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605160620.ReBOadPX-lkp@xxxxxxxxx/
> Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
>
> ---
> Changes in v2:
> - Fix variable name typo: use 'retval' instead of 'ret' (reported by test robot)
> ---
> drivers/gpib/cb7210/cb7210.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpib/cb7210/cb7210.c b/drivers/gpib/cb7210/cb7210.c
> index 6dd8637c5964..673b5bfe2e7d 100644
> --- a/drivers/gpib/cb7210/cb7210.c
> +++ b/drivers/gpib/cb7210/cb7210.c
> @@ -1049,7 +1049,8 @@ static int cb_isa_attach(struct gpib_board *board, const struct gpib_board_confi
> if (!request_region(config->ibbase, cb7210_iosize, DRV_NAME)) {
> dev_err(board->gpib_dev, "ioports starting at 0x%x are already in use\n",
> config->ibbase);
> - return -EBUSY;
> + retval = -EBUSY;
> + goto err_release_region;
> }
> nec_priv->iobase = config->ibbase;
> cb_priv->fifo_iobase = nec7210_iobase(cb_priv);
> @@ -1062,11 +1063,16 @@ static int cb_isa_attach(struct gpib_board *board, const struct gpib_board_confi
> // install interrupt handler
> if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, DRV_NAME, board)) {
> dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", config->ibirq);
> - return -EBUSY;
> + retval = -EBUSY;
> + goto err_release_region;
> }
> cb_priv->irq = config->ibirq;
>
> return cb7210_init(cb_priv, board);
> +
> +err_release_region:
> + release_region(nec7210_iobase(cb_priv), cb7210_iosize);
> + return retval;
> }
>
> static void cb_isa_detach(struct gpib_board *board)
> --
> 2.25.1
>
>