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

Hongling Zeng posted 1 patch 1 month, 1 week ago
There is a newer version of this series
drivers/gpib/cb7210/cb7210.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by Hongling Zeng 1 month, 1 week ago
When request_irq() fails, the region allocated by request_region()
is not released. Fix this by calling release_region() before returning.

  Smatch warning:
    drivers/gpib/cb7210/cb7210.c:1068 cb_isa_attach() warn: 'config->ibbase'
  from __request_region() not released on lines: 1064.

Fixes: 82e3508046f9b ("gpib: cb7210: add isa support module")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
 drivers/gpib/cb7210/cb7210.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpib/cb7210/cb7210.c b/drivers/gpib/cb7210/cb7210.c
index 6dd8637c5964..05058bf2cd50 100644
--- a/drivers/gpib/cb7210/cb7210.c
+++ b/drivers/gpib/cb7210/cb7210.c
@@ -1062,6 +1062,7 @@ 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);
+		release_region(nec7210_iobase(cb_priv), cb7210_iosize);
 		return -EBUSY;
 	}
 	cb_priv->irq = config->ibirq;
-- 
2.25.1
Re: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by Dominik Karol Piątkowski 2 weeks, 2 days ago
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/

I believe this patch should be reverted.

Thanks,
Dominik Karol

On Sunday, May 3rd, 2026 at 11:30, Hongling Zeng <zenghongling@kylinos.cn> wrote:

> When request_irq() fails, the region allocated by request_region()
> is not released. Fix this by calling release_region() before returning.
> 
>   Smatch warning:
>     drivers/gpib/cb7210/cb7210.c:1068 cb_isa_attach() warn: 'config->ibbase'
>   from __request_region() not released on lines: 1064.
> 
> Fixes: 82e3508046f9b ("gpib: cb7210: add isa support module")
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>  drivers/gpib/cb7210/cb7210.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpib/cb7210/cb7210.c b/drivers/gpib/cb7210/cb7210.c
> index 6dd8637c5964..05058bf2cd50 100644
> --- a/drivers/gpib/cb7210/cb7210.c
> +++ b/drivers/gpib/cb7210/cb7210.c
> @@ -1062,6 +1062,7 @@ 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);
> +		release_region(nec7210_iobase(cb_priv), cb7210_iosize);
>  		return -EBUSY;
>  	}
>  	cb_priv->irq = config->ibirq;
> --
> 2.25.1
> 
>