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

Hongling Zeng posted 1 patch 4 weeks ago
There is a newer version of this series
drivers/gpib/cb7210/cb7210.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
[PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by Hongling Zeng 4 weeks ago
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: 82e3508046f9b ("gpib: cb7210: add isa support module")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
 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..7b0af517cf14 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;
+		ret = -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
Re: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by kernel test robot 3 weeks, 6 days ago
Hi Hongling,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hongling-Zeng/gpib-cb7210-Fix-region-leak-when-request_irq-fails/20260515-222229
base:   linus/master
patch link:    https://lore.kernel.org/r/20260515073952.54359-1-zenghongling%40kylinos.cn
patch subject: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
config: x86_64-randconfig-076-20260516 (https://download.01.org/0day-ci/archive/20260516/202605160620.ReBOadPX-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260516/202605160620.ReBOadPX-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605160620.ReBOadPX-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/gpib/cb7210/cb7210.c:1066:3: error: use of undeclared identifier 'ret'
    1066 |                 ret = -EBUSY;
         |                 ^
   1 error generated.


vim +/ret +1066 drivers/gpib/cb7210/cb7210.c

  1035	
  1036	static int cb_isa_attach(struct gpib_board *board, const struct gpib_board_config *config)
  1037	{
  1038		int isr_flags = 0;
  1039		struct cb7210_priv *cb_priv;
  1040		struct nec7210_priv *nec_priv;
  1041		unsigned int bits;
  1042		int retval;
  1043	
  1044		retval = cb7210_generic_attach(board);
  1045		if (retval)
  1046			return retval;
  1047		cb_priv = board->private_data;
  1048		nec_priv = &cb_priv->nec7210_priv;
  1049		if (!request_region(config->ibbase, cb7210_iosize, DRV_NAME)) {
  1050			dev_err(board->gpib_dev, "ioports starting at 0x%x are already in use\n",
  1051				config->ibbase);
  1052			retval = -EBUSY;
  1053			goto err_release_region;
  1054		}
  1055		nec_priv->iobase = config->ibbase;
  1056		cb_priv->fifo_iobase = nec7210_iobase(cb_priv);
  1057	
  1058		bits = irq_bits(config->ibirq);
  1059		if (bits == 0)
  1060			dev_err(board->gpib_dev, "board incapable of using irq %i, try 2-5, 7, 10, or 11\n",
  1061				config->ibirq);
  1062	
  1063		// install interrupt handler
  1064		if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, DRV_NAME, board)) {
  1065			dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", config->ibirq);
> 1066			ret = -EBUSY;
  1067			goto err_release_region;
  1068		}
  1069		cb_priv->irq = config->ibirq;
  1070	
  1071		return cb7210_init(cb_priv, board);
  1072	
  1073	err_release_region:
  1074		release_region(nec7210_iobase(cb_priv), cb7210_iosize);
  1075		return retval;
  1076	}
  1077	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by Hongling Zeng 3 weeks, 4 days ago
   Hi,

   Thanks for the report. The issue is a typo where I used 'ret' instead of
   'retval'. I'll fix this in v2 and add the appropriate tags.

   Best regards,
   Hongling

在 2026年05月16日 06:23, kernel test robot 写道:
> Hi Hongling,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on linus/master]
> [also build test ERROR on v7.1-rc3 next-20260508]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Hongling-Zeng/gpib-cb7210-Fix-region-leak-when-request_irq-fails/20260515-222229
> base:   linus/master
> patch link:    https://lore.kernel.org/r/20260515073952.54359-1-zenghongling%40kylinos.cn
> patch subject: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
> config: x86_64-randconfig-076-20260516 (https://download.01.org/0day-ci/archive/20260516/202605160620.ReBOadPX-lkp@intel.com/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260516/202605160620.ReBOadPX-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202605160620.ReBOadPX-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>>> drivers/gpib/cb7210/cb7210.c:1066:3: error: use of undeclared identifier 'ret'
>      1066 |                 ret = -EBUSY;
>           |                 ^
>     1 error generated.
>
>
> vim +/ret +1066 drivers/gpib/cb7210/cb7210.c
>
>    1035	
>    1036	static int cb_isa_attach(struct gpib_board *board, const struct gpib_board_config *config)
>    1037	{
>    1038		int isr_flags = 0;
>    1039		struct cb7210_priv *cb_priv;
>    1040		struct nec7210_priv *nec_priv;
>    1041		unsigned int bits;
>    1042		int retval;
>    1043	
>    1044		retval = cb7210_generic_attach(board);
>    1045		if (retval)
>    1046			return retval;
>    1047		cb_priv = board->private_data;
>    1048		nec_priv = &cb_priv->nec7210_priv;
>    1049		if (!request_region(config->ibbase, cb7210_iosize, DRV_NAME)) {
>    1050			dev_err(board->gpib_dev, "ioports starting at 0x%x are already in use\n",
>    1051				config->ibbase);
>    1052			retval = -EBUSY;
>    1053			goto err_release_region;
>    1054		}
>    1055		nec_priv->iobase = config->ibbase;
>    1056		cb_priv->fifo_iobase = nec7210_iobase(cb_priv);
>    1057	
>    1058		bits = irq_bits(config->ibirq);
>    1059		if (bits == 0)
>    1060			dev_err(board->gpib_dev, "board incapable of using irq %i, try 2-5, 7, 10, or 11\n",
>    1061				config->ibirq);
>    1062	
>    1063		// install interrupt handler
>    1064		if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, DRV_NAME, board)) {
>    1065			dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", config->ibirq);
>> 1066			ret = -EBUSY;
>    1067			goto err_release_region;
>    1068		}
>    1069		cb_priv->irq = config->ibirq;
>    1070	
>    1071		return cb7210_init(cb_priv, board);
>    1072	
>    1073	err_release_region:
>    1074		release_region(nec7210_iobase(cb_priv), cb7210_iosize);
>    1075		return retval;
>    1076	}
>    1077	
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

Re: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by kernel test robot 3 weeks, 6 days ago
Hi Hongling,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hongling-Zeng/gpib-cb7210-Fix-region-leak-when-request_irq-fails/20260515-222229
base:   linus/master
patch link:    https://lore.kernel.org/r/20260515073952.54359-1-zenghongling%40kylinos.cn
patch subject: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
config: x86_64-randconfig-071-20260516 (https://download.01.org/0day-ci/archive/20260516/202605160539.Ztg2yanl-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260516/202605160539.Ztg2yanl-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605160539.Ztg2yanl-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/gpib/cb7210/cb7210.c: In function 'cb_isa_attach':
>> drivers/gpib/cb7210/cb7210.c:1066:17: error: 'ret' undeclared (first use in this function); did you mean 'net'?
    1066 |                 ret = -EBUSY;
         |                 ^~~
         |                 net
   drivers/gpib/cb7210/cb7210.c:1066:17: note: each undeclared identifier is reported only once for each function it appears in


vim +1066 drivers/gpib/cb7210/cb7210.c

  1035	
  1036	static int cb_isa_attach(struct gpib_board *board, const struct gpib_board_config *config)
  1037	{
  1038		int isr_flags = 0;
  1039		struct cb7210_priv *cb_priv;
  1040		struct nec7210_priv *nec_priv;
  1041		unsigned int bits;
  1042		int retval;
  1043	
  1044		retval = cb7210_generic_attach(board);
  1045		if (retval)
  1046			return retval;
  1047		cb_priv = board->private_data;
  1048		nec_priv = &cb_priv->nec7210_priv;
  1049		if (!request_region(config->ibbase, cb7210_iosize, DRV_NAME)) {
  1050			dev_err(board->gpib_dev, "ioports starting at 0x%x are already in use\n",
  1051				config->ibbase);
  1052			retval = -EBUSY;
  1053			goto err_release_region;
  1054		}
  1055		nec_priv->iobase = config->ibbase;
  1056		cb_priv->fifo_iobase = nec7210_iobase(cb_priv);
  1057	
  1058		bits = irq_bits(config->ibirq);
  1059		if (bits == 0)
  1060			dev_err(board->gpib_dev, "board incapable of using irq %i, try 2-5, 7, 10, or 11\n",
  1061				config->ibirq);
  1062	
  1063		// install interrupt handler
  1064		if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, DRV_NAME, board)) {
  1065			dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", config->ibirq);
> 1066			ret = -EBUSY;
  1067			goto err_release_region;
  1068		}
  1069		cb_priv->irq = config->ibirq;
  1070	
  1071		return cb7210_init(cb_priv, board);
  1072	
  1073	err_release_region:
  1074		release_region(nec7210_iobase(cb_priv), cb7210_iosize);
  1075		return retval;
  1076	}
  1077	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] gpib: cb7210: Fix region leak when request_irq fails
Posted by Greg KH 4 weeks ago
On Fri, May 15, 2026 at 03:39:52PM +0800, Hongling Zeng 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: 82e3508046f9b ("gpib: cb7210: add isa support module")
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>  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..7b0af517cf14 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;
> +		ret = -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
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot