[media] rc: Fix invalid free_region and/or free_irq on probe failure

fintek-cir, ite-cir and nuvoton-cir may try to free an I/O region
and/or IRQ handler that was never allocated after a failure in their
respective probe functions.  Add and use separate labels on the
failure path so they will do the right cleanup after each possible
point of failure.

Compile-tested only.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
这个提交包含在:
Ben Hutchings
2012-05-14 21:36:00 -03:00
提交者 Mauro Carvalho Chehab
父节点 81cda57742
当前提交 f27b853ea2
修改 3 个文件,包含 24 行新增29 行删除

查看文件

@@ -1075,19 +1075,19 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED,
NVT_DRIVER_NAME, (void *)nvt))
goto failure;
goto failure2;
if (!request_region(nvt->cir_wake_addr,
CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
goto failure;
goto failure3;
if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED,
NVT_DRIVER_NAME, (void *)nvt))
goto failure;
goto failure4;
ret = rc_register_device(rdev);
if (ret)
goto failure;
goto failure5;
device_init_wakeup(&pdev->dev, true);
nvt->rdev = rdev;
@@ -1099,17 +1099,15 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
return 0;
failure5:
free_irq(nvt->cir_wake_irq, nvt);
failure4:
release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
failure3:
free_irq(nvt->cir_irq, nvt);
failure2:
release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
failure:
if (nvt->cir_irq)
free_irq(nvt->cir_irq, nvt);
if (nvt->cir_addr)
release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
if (nvt->cir_wake_irq)
free_irq(nvt->cir_wake_irq, nvt);
if (nvt->cir_wake_addr)
release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
rc_free_device(rdev);
kfree(nvt);