]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpib: cb7210: Fix region leak when request_irq fails
authorHongling Zeng <zenghongling@kylinos.cn>
Mon, 18 May 2026 02:29:39 +0000 (10:29 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 May 2026 10:19:02 +0000 (12:19 +0200)
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")
Closes: https://lore.kernel.org/oe-kbuild-all/202605160620.ReBOadPX-lkp@intel.com/
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Cc: stable <stable@kernel.org>
Link: https://patch.msgid.link/20260518022939.16881-1-zenghongling@kylinos.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpib/cb7210/cb7210.c

index 6dd8637c5964b358874a5981587e2040195aa67a..673b5bfe2e7d15be130b12c04aa07e59bfc5fdfe 100644 (file)
@@ -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)