Messages in this thread Patch in this message | | | From | Tiezhu Yang <> | Subject | [PATCH v5 13/14] irqchip/s3c24xx: Fix potential resource leaks | Date | Mon, 6 Jul 2020 09:19:24 +0800 |
| |
In the function s3c_init_intc_of(), system resource "reg_base", "domain" and "intc" were not released in a few error cases. Thus add jump targets for the completion of the desired exception handling.
Fixes: f0774d41da0e ("irqchip: s3c24xx: add devicetree support") Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> --- drivers/irqchip/irq-s3c24xx.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c index d2031fe..cf48e4b 100644 --- a/drivers/irqchip/irq-s3c24xx.c +++ b/drivers/irqchip/irq-s3c24xx.c @@ -1227,7 +1227,7 @@ static int __init s3c_init_intc_of(struct device_node *np, struct s3c24xx_irq_of_ctrl *ctrl; struct irq_domain *domain; void __iomem *reg_base; - int i; + int i, ret; reg_base = of_iomap(np, 0); if (!reg_base) { @@ -1239,7 +1239,8 @@ static int __init s3c_init_intc_of(struct device_node *np, &s3c24xx_irq_ops_of, NULL); if (!domain) { pr_err("irq: could not create irq-domain\n"); - return -EINVAL; + ret = -EINVAL; + goto err_iounmap; } for (i = 0; i < num_ctrl; i++) { @@ -1248,15 +1249,17 @@ static int __init s3c_init_intc_of(struct device_node *np, pr_debug("irq: found controller %s\n", ctrl->name); intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL); - if (!intc) - return -ENOMEM; + if (!intc) { + ret = -ENOMEM; + goto err_domain_remove; + } intc->domain = domain; intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data), GFP_KERNEL); if (!intc->irqs) { - kfree(intc); - return -ENOMEM; + ret = -ENOMEM; + goto err_free; } if (ctrl->parent) { @@ -1285,6 +1288,14 @@ static int __init s3c_init_intc_of(struct device_node *np, set_handle_irq(s3c24xx_handle_irq); return 0; + +err_free: + kfree(intc); +err_domain_remove: + irq_domain_remove(domain); +err_iounmap: + iounmap(reg_base); + return ret; } static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = { -- 2.1.0
| |