Skip to content

Commit c5a9c86

Browse files
zenghongling0719gregkh
authored andcommitted
parisc: Fix IRQ leak in LASI driver
commit 37b0dc5 upstream. When request_irq() succeeds but gsc_common_setup() fails later, the IRQ is never released. Fix this by adding proper error handling with goto labels to ensure resources are released in LIFO order. Detected by Smatch: drivers/parisc/lasi.c:216 lasi_init_chip() warn: 'lasi->gsc_irq.irq' from request_irq() not released on lines: 207. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Closes: https://lore.kernel.org/r/202604180957.4QdAIxP6-lkp@intel.com/ Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn> Cc: stable@vger.kernel.org Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9855e06 commit c5a9c86

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/parisc/lasi.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ static int __init lasi_init_chip(struct parisc_device *dev)
193193

194194
ret = request_irq(lasi->gsc_irq.irq, gsc_asic_intr, 0, "lasi", lasi);
195195
if (ret < 0) {
196-
kfree(lasi);
197-
return ret;
196+
goto err_free;
198197
}
199198

200199
/* enable IRQ's for devices below LASI */
@@ -203,8 +202,7 @@ static int __init lasi_init_chip(struct parisc_device *dev)
203202
/* Done init'ing, register this driver */
204203
ret = gsc_common_setup(dev, lasi);
205204
if (ret) {
206-
kfree(lasi);
207-
return ret;
205+
goto err_irq;
208206
}
209207

210208
gsc_fixup_irqs(dev, lasi, lasi_choose_irq);
@@ -214,6 +212,12 @@ static int __init lasi_init_chip(struct parisc_device *dev)
214212
SYS_OFF_PRIO_DEFAULT, lasi_power_off, lasi);
215213

216214
return ret;
215+
216+
err_irq:
217+
free_irq(lasi->gsc_irq.irq, lasi);
218+
err_free:
219+
kfree(lasi);
220+
return ret;
217221
}
218222

219223
static struct parisc_device_id lasi_tbl[] __initdata = {

0 commit comments

Comments
 (0)