linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/14] irqchip: Fix potential resource leaks
@ 2020-06-24  6:32 Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 01/14] irqchip/ath79-misc: " Tiezhu Yang
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

When I test the irqchip code of Loongson, I read the related code of other
chips in drivers/irqchip and I find some potential resource leaks in the
error path, I think it is better to fix them.

v2:
  - Split the first patch into a new patch series which
    includes small patches and add "Fixes" tag
  - Use "goto" label to handle error path in some patches

Tiezhu Yang (14):
  irqchip/ath79-misc: Fix potential resource leaks
  irqchip/csky-apb-intc: Fix potential resource leaks
  irqchip/csky-mpintc: Fix potential resource leaks
  irqchip/davinci-aintc: Fix potential resource leaks
  irqchip/davinci-cp-intc: Fix potential resource leaks
  irqchip/digicolor: Fix potential resource leaks
  irqchip/dw-apb-ictl: Fix potential resource leaks
  irqchip/ls1x: Fix potential resource leaks
  irqchip/mscc-ocelot: Fix potential resource leaks
  irqchip/nvic: Fix potential resource leaks
  irqchip/omap-intc: Fix potential resource leak
  irqchip/riscv-intc: Fix potential resource leak
  irqchip/s3c24xx: Fix potential resource leaks
  irqchip/xilinx-intc: Fix potential resource leak

 drivers/irqchip/irq-ath79-misc.c      | 14 +++++++++++---
 drivers/irqchip/irq-csky-apb-intc.c   | 12 ++++++++++--
 drivers/irqchip/irq-csky-mpintc.c     | 26 ++++++++++++++++++++------
 drivers/irqchip/irq-davinci-aintc.c   | 17 +++++++++++++----
 drivers/irqchip/irq-davinci-cp-intc.c | 17 ++++++++++++++---
 drivers/irqchip/irq-digicolor.c       | 14 +++++++++++---
 drivers/irqchip/irq-dw-apb-ictl.c     | 11 ++++++++---
 drivers/irqchip/irq-ls1x.c            |  4 +++-
 drivers/irqchip/irq-mscc-ocelot.c     |  6 ++++--
 drivers/irqchip/irq-nvic.c            | 12 +++++++++---
 drivers/irqchip/irq-omap-intc.c       |  4 +++-
 drivers/irqchip/irq-riscv-intc.c      |  1 +
 drivers/irqchip/irq-s3c24xx.c         | 20 +++++++++++++++-----
 drivers/irqchip/irq-xilinx-intc.c     |  4 +++-
 14 files changed, 125 insertions(+), 37 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 01/14] irqchip/ath79-misc: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 02/14] irqchip/csky-apb-intc: " Tiezhu Yang
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 07ba4b061a79 ("irqchip/ath79-misc: Move the MISC driver from arch/mips/ath79/")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-ath79-misc.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c
index 3d641bb..53e0c50 100644
--- a/drivers/irqchip/irq-ath79-misc.c
+++ b/drivers/irqchip/irq-ath79-misc.c
@@ -133,7 +133,7 @@ static int __init ath79_misc_intc_of_init(
 {
 	struct irq_domain *domain;
 	void __iomem *base;
-	int irq;
+	int irq, ret;
 
 	irq = irq_of_parse_and_map(node, 0);
 	if (!irq) {
@@ -144,18 +144,26 @@ static int __init ath79_misc_intc_of_init(
 	base = of_iomap(node, 0);
 	if (!base) {
 		pr_err("Failed to get MISC IRQ registers\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_irq_dispose;
 	}
 
 	domain = irq_domain_add_linear(node, ATH79_MISC_IRQ_COUNT,
 				&misc_irq_domain_ops, base);
 	if (!domain) {
 		pr_err("Failed to add MISC irqdomain\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_iounmap;
 	}
 
 	ath79_misc_intc_domain_init(domain, irq);
 	return 0;
+
+err_iounmap:
+	iounmap(base);
+err_irq_dispose:
+	irq_dispose_mapping(irq);
+	return ret;
 }
 
 static int __init ar7100_misc_intc_of_init(
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 02/14] irqchip/csky-apb-intc: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 01/14] irqchip/ath79-misc: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 03/14] irqchip/csky-mpintc: " Tiezhu Yang
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-csky-apb-intc.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index 5a2ec43..11a35eb 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -118,7 +118,8 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
 					    &irq_generic_chip_ops, NULL);
 	if (!root_domain) {
 		pr_err("C-SKY Intc irq_domain_add failed.\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_iounmap;
 	}
 
 	ret = irq_alloc_domain_generic_chips(root_domain, 32, 1,
@@ -126,10 +127,17 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
 			IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0);
 	if (ret) {
 		pr_err("C-SKY Intc irq_alloc_gc failed.\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_domain_remove;
 	}
 
 	return 0;
+
+err_domain_remove:
+	irq_domain_remove(root_domain);
+err_iounmap:
+	iounmap(reg_base);
+	return ret;
 }
 
 static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 03/14] irqchip/csky-mpintc: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 01/14] irqchip/ath79-misc: " Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 02/14] irqchip/csky-apb-intc: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 04/14] irqchip/davinci-aintc: " Tiezhu Yang
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-csky-mpintc.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c
index a1534ed..c195e24 100644
--- a/drivers/irqchip/irq-csky-mpintc.c
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
 	if (INTCG_base == NULL) {
 		INTCG_base = ioremap(mfcr("cr<31, 14>"),
 				     INTCL_SIZE*nr_cpu_ids + INTCG_SIZE);
-		if (INTCG_base == NULL)
-			return -EIO;
+		if (INTCG_base == NULL) {
+			ret = -EIO;
+			goto err_free;
+		}
 
 		INTCL_base = INTCG_base + INTCG_SIZE;
 
@@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
 
 	root_domain = irq_domain_add_linear(node, nr_irq, &csky_irqdomain_ops,
 					    NULL);
-	if (!root_domain)
-		return -ENXIO;
+	if (!root_domain) {
+		ret = -ENXIO;
+		goto err_iounmap;
+	}
 
 	/* for every cpu */
 	for_each_present_cpu(cpu) {
@@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
 
 #ifdef CONFIG_SMP
 	ipi_irq = irq_create_mapping(root_domain, IPI_IRQ);
-	if (!ipi_irq)
-		return -EIO;
+	if (!ipi_irq) {
+		ret = -EIO;
+		goto err_domain_remove;
+	}
 
 	set_send_ipi(&csky_mpintc_send_ipi, ipi_irq);
 #endif
 
 	return 0;
+
+err_domain_remove:
+	irq_domain_remove(root_domain);
+err_iounmap:
+	iounmap(INTCG_base);
+err_free:
+	kfree(__trigger);
+	return ret;
 }
 IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 04/14] irqchip/davinci-aintc: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (2 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 03/14] irqchip/csky-mpintc: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 05/14] irqchip/davinci-cp-intc: " Tiezhu Yang
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to drivers/irqchip")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-davinci-aintc.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-davinci-aintc.c b/drivers/irqchip/irq-davinci-aintc.c
index 810ccc4..12db502 100644
--- a/drivers/irqchip/irq-davinci-aintc.c
+++ b/drivers/irqchip/irq-davinci-aintc.c
@@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
 				     resource_size(&config->reg));
 	if (!davinci_aintc_base) {
 		pr_err("%s: unable to ioremap register range\n", __func__);
-		return;
+		goto err_release;
 	}
 
 	/* Clear all interrupt requests */
@@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
 	if (irq_base < 0) {
 		pr_err("%s: unable to allocate interrupt descriptors: %d\n",
 		       __func__, irq_base);
-		return;
+		goto err_iounmap;
 	}
 
 	davinci_aintc_irq_domain = irq_domain_add_legacy(NULL,
@@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
 						&irq_domain_simple_ops, NULL);
 	if (!davinci_aintc_irq_domain) {
 		pr_err("%s: unable to create interrupt domain\n", __func__);
-		return;
+		goto err_free_descs;
 	}
 
 	ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1,
@@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
 	if (ret) {
 		pr_err("%s: unable to allocate generic irq chips for domain\n",
 		       __func__);
-		return;
+		goto err_domain_remove;
 	}
 
 	for (irq_off = 0, reg_off = 0;
@@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
 				       irq_base + irq_off, 32);
 
 	set_handle_irq(davinci_aintc_handle_irq);
+
+err_domain_remove:
+	irq_domain_remove(davinci_aintc_irq_domain);
+err_free_descs:
+	irq_free_descs(irq_base, config->num_irqs);
+err_iounmap:
+	iounmap(davinci_aintc_base);
+err_release:
+	release_mem_region(config->reg.start, resource_size(&config->reg));
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 05/14] irqchip/davinci-cp-intc: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (3 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 04/14] irqchip/davinci-aintc: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 06/14] irqchip/digicolor: " Tiezhu Yang
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to drivers/irqchip")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-davinci-cp-intc.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-davinci-cp-intc.c b/drivers/irqchip/irq-davinci-cp-intc.c
index 276da277..991339f 100644
--- a/drivers/irqchip/irq-davinci-cp-intc.c
+++ b/drivers/irqchip/irq-davinci-cp-intc.c
@@ -175,7 +175,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
 				       resource_size(&config->reg));
 	if (!davinci_cp_intc_base) {
 		pr_err("%s: unable to ioremap register range\n", __func__);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_release;
 	}
 
 	davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE);
@@ -210,7 +211,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
 	if (irq_base < 0) {
 		pr_err("%s: unable to allocate interrupt descriptors: %d\n",
 		       __func__, irq_base);
-		return irq_base;
+		ret = irq_base;
+		goto err_iounmap;
 	}
 
 	davinci_cp_intc_irq_domain = irq_domain_add_legacy(
@@ -219,7 +221,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
 
 	if (!davinci_cp_intc_irq_domain) {
 		pr_err("%s: unable to create an interrupt domain\n", __func__);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_free_descs;
 	}
 
 	set_handle_irq(davinci_cp_intc_handle_irq);
@@ -228,6 +231,14 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
 	davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE);
 
 	return 0;
+
+err_free_descs:
+	irq_free_descs(irq_base, config->num_irqs);
+err_iounmap:
+	iounmap(davinci_cp_intc_base);
+err_release:
+	release_mem_region(config->reg.start, resource_size(&config->reg));
+	return ret;
 }
 
 int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 06/14] irqchip/digicolor: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (4 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 05/14] irqchip/davinci-cp-intc: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 07/14] irqchip/dw-apb-ictl: " Tiezhu Yang
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 8041dfbd31cf ("irqchip: Conexant CX92755 interrupts controller driver")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-digicolor.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c
index fc38d2d..18c6e77 100644
--- a/drivers/irqchip/irq-digicolor.c
+++ b/drivers/irqchip/irq-digicolor.c
@@ -89,7 +89,8 @@ static int __init digicolor_of_init(struct device_node *node,
 	ucregs = syscon_regmap_lookup_by_phandle(node, "syscon");
 	if (IS_ERR(ucregs)) {
 		pr_err("%pOF: unable to map UC registers\n", node);
-		return PTR_ERR(ucregs);
+		ret = PTR_ERR(ucregs);
+		goto err_iounmap;
 	}
 	/* channel 1, regular IRQs */
 	regmap_write(ucregs, UC_IRQ_CONTROL, 1);
@@ -98,7 +99,8 @@ static int __init digicolor_of_init(struct device_node *node,
 		irq_domain_add_linear(node, 64, &irq_generic_chip_ops, NULL);
 	if (!digicolor_irq_domain) {
 		pr_err("%pOF: unable to create IRQ domain\n", node);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_iounmap;
 	}
 
 	ret = irq_alloc_domain_generic_chips(digicolor_irq_domain, 32, 1,
@@ -106,7 +108,7 @@ static int __init digicolor_of_init(struct device_node *node,
 					     clr, 0, 0);
 	if (ret) {
 		pr_err("%pOF: unable to allocate IRQ gc\n", node);
-		return ret;
+		goto err_domain_remove;
 	}
 
 	digicolor_set_gc(reg_base, 0, IC_INT0ENABLE_LO, IC_FLAG_CLEAR_LO);
@@ -115,5 +117,11 @@ static int __init digicolor_of_init(struct device_node *node,
 	set_handle_irq(digicolor_handle_irq);
 
 	return 0;
+
+err_domain_remove:
+	irq_domain_remove(digicolor_irq_domain);
+err_iounmap:
+	iounmap(reg_base);
+	return ret;
 }
 IRQCHIP_DECLARE(conexant_digicolor_ic, "cnxt,cx92755-ic", digicolor_of_init);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 07/14] irqchip/dw-apb-ictl: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (5 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 06/14] irqchip/digicolor: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 08/14] irqchip/ls1x: " Tiezhu Yang
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 350d71b94fc9 ("irqchip: add DesignWare APB ICTL interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-dw-apb-ictl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c
index e4550e9..bc9b750 100644
--- a/drivers/irqchip/irq-dw-apb-ictl.c
+++ b/drivers/irqchip/irq-dw-apb-ictl.c
@@ -86,12 +86,13 @@ static int __init dw_apb_ictl_init(struct device_node *np,
 	ret = of_address_to_resource(np, 0, &r);
 	if (ret) {
 		pr_err("%pOF: unable to get resource\n", np);
-		return ret;
+		goto err_irq_dispose;
 	}
 
 	if (!request_mem_region(r.start, resource_size(&r), np->full_name)) {
 		pr_err("%pOF: unable to request mem region\n", np);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_irq_dispose;
 	}
 
 	iobase = ioremap(r.start, resource_size(&r));
@@ -133,7 +134,7 @@ static int __init dw_apb_ictl_init(struct device_node *np,
 					     IRQ_GC_INIT_MASK_CACHE);
 	if (ret) {
 		pr_err("%pOF: unable to alloc irq domain gc\n", np);
-		goto err_unmap;
+		goto err_domain_remove;
 	}
 
 	for (i = 0; i < DIV_ROUND_UP(nrirqs, 32); i++) {
@@ -150,10 +151,14 @@ static int __init dw_apb_ictl_init(struct device_node *np,
 
 	return 0;
 
+err_domain_remove:
+	irq_domain_remove(domain);
 err_unmap:
 	iounmap(iobase);
 err_release:
 	release_mem_region(r.start, resource_size(&r));
+err_irq_dispose:
+	irq_dispose_mapping(irq);
 	return ret;
 }
 IRQCHIP_DECLARE(dw_apb_ictl,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 08/14] irqchip/ls1x: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (6 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 07/14] irqchip/dw-apb-ictl: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 09/14] irqchip/mscc-ocelot: " Tiezhu Yang
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 9e543e22e204 ("irqchip: Add driver for Loongson-1 interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-ls1x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-ls1x.c b/drivers/irqchip/irq-ls1x.c
index 353111a..409001b 100644
--- a/drivers/irqchip/irq-ls1x.c
+++ b/drivers/irqchip/irq-ls1x.c
@@ -131,7 +131,7 @@ static int __init ls1x_intc_of_init(struct device_node *node,
 	if (!priv->domain) {
 		pr_err("ls1x-irq: cannot add IRQ domain\n");
 		err = -ENOMEM;
-		goto out_iounmap;
+		goto out_dispose_irq;
 	}
 
 	err = irq_alloc_domain_generic_chips(priv->domain, 32, 2,
@@ -182,6 +182,8 @@ static int __init ls1x_intc_of_init(struct device_node *node,
 
 out_free_domain:
 	irq_domain_remove(priv->domain);
+out_dispose_irq:
+	irq_dispose_mapping(parent_irq);
 out_iounmap:
 	iounmap(priv->intc_base);
 out_free_priv:
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 09/14] irqchip/mscc-ocelot: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (7 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 08/14] irqchip/ls1x: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 10/14] irqchip/nvic: " Tiezhu Yang
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 19d99164480a ("irqchip: Add a driver for the Microsemi Ocelot controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-mscc-ocelot.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-mscc-ocelot.c b/drivers/irqchip/irq-mscc-ocelot.c
index 88143c0..e676ae2 100644
--- a/drivers/irqchip/irq-mscc-ocelot.c
+++ b/drivers/irqchip/irq-mscc-ocelot.c
@@ -73,7 +73,8 @@ static int __init ocelot_irq_init(struct device_node *node,
 				       &irq_generic_chip_ops, NULL);
 	if (!domain) {
 		pr_err("%pOFn: unable to add irq domain\n", node);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_irq_dispose;
 	}
 
 	ret = irq_alloc_domain_generic_chips(domain, OCELOT_NR_IRQ, 1,
@@ -109,9 +110,10 @@ static int __init ocelot_irq_init(struct device_node *node,
 
 err_gc_free:
 	irq_free_generic_chip(gc);
-
 err_domain_remove:
 	irq_domain_remove(domain);
+err_irq_dispose:
+	irq_dispose_mapping(parent_irq);
 
 	return ret;
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 10/14] irqchip/nvic: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (8 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 09/14] irqchip/mscc-ocelot: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 11/14] irqchip/omap-intc: Fix potential resource leak Tiezhu Yang
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: 292ec080491d ("irqchip: Add support for ARMv7-M NVIC")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-nvic.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c
index f747e22..cd17f5d 100644
--- a/drivers/irqchip/irq-nvic.c
+++ b/drivers/irqchip/irq-nvic.c
@@ -94,7 +94,8 @@ static int __init nvic_of_init(struct device_node *node,
 
 	if (!nvic_irq_domain) {
 		pr_warn("Failed to allocate irq domain\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_iounmap;
 	}
 
 	ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1,
@@ -102,8 +103,7 @@ static int __init nvic_of_init(struct device_node *node,
 					     clr, 0, IRQ_GC_INIT_MASK_CACHE);
 	if (ret) {
 		pr_warn("Failed to allocate irq chips\n");
-		irq_domain_remove(nvic_irq_domain);
-		return ret;
+		goto err_domain_remove;
 	}
 
 	for (i = 0; i < numbanks; ++i) {
@@ -129,5 +129,11 @@ static int __init nvic_of_init(struct device_node *node,
 		writel_relaxed(0, nvic_base + NVIC_IPR + i);
 
 	return 0;
+
+err_domain_remove:
+	irq_domain_remove(nvic_irq_domain);
+err_iounmap:
+	iounmap(nvic_base);
+	return ret;
 }
 IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 11/14] irqchip/omap-intc: Fix potential resource leak
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (9 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 10/14] irqchip/nvic: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 12/14] irqchip/riscv-intc: " Tiezhu Yang
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leak in the error path, fix it.

Fixes: 8598066cddd1 ("arm: omap: irq: move irq.c to drivers/irqchip/")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-omap-intc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-omap-intc.c b/drivers/irqchip/irq-omap-intc.c
index d360a6e..e711530 100644
--- a/drivers/irqchip/irq-omap-intc.c
+++ b/drivers/irqchip/irq-omap-intc.c
@@ -254,8 +254,10 @@ static int __init omap_init_irq_of(struct device_node *node)
 	omap_irq_soft_reset();
 
 	ret = omap_alloc_gc_of(domain, omap_irq_base);
-	if (ret < 0)
+	if (ret < 0) {
 		irq_domain_remove(domain);
+		iounmap(omap_irq_base);
+	}
 
 	return ret;
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 12/14] irqchip/riscv-intc: Fix potential resource leak
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (10 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 11/14] irqchip/omap-intc: Fix potential resource leak Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks Tiezhu Yang
  2020-06-24  6:32 ` [PATCH v2 14/14] irqchip/xilinx-intc: Fix potential resource leak Tiezhu Yang
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leak in the error path, fix it.

Fixes: 6b7ce8927b5a ("irqchip: RISC-V per-HART local interrupt controller driver")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-riscv-intc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c
index a6f97fa..8d6286c 100644
--- a/drivers/irqchip/irq-riscv-intc.c
+++ b/drivers/irqchip/irq-riscv-intc.c
@@ -122,6 +122,7 @@ static int __init riscv_intc_init(struct device_node *node,
 	rc = set_handle_irq(&riscv_intc_irq);
 	if (rc) {
 		pr_err("failed to set irq handler\n");
+		irq_domain_remove(intc_domain);
 		return rc;
 	}
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (11 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 12/14] irqchip/riscv-intc: " Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  2020-06-24 22:38   ` kernel test robot
  2020-06-25 14:17   ` kernel test robot
  2020-06-24  6:32 ` [PATCH v2 14/14] irqchip/xilinx-intc: Fix potential resource leak Tiezhu Yang
  13 siblings, 2 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leaks in the error path, fix them.

Fixes: f0774d41da0e ("irqchip: s3c24xx: add devicetree support")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-s3c24xx.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index d2031fe..ef5d645 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -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 out_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 out_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 out_free;
 		}
 
 		if (ctrl->parent) {
@@ -1285,6 +1288,13 @@ static int __init s3c_init_intc_of(struct device_node *np,
 	set_handle_irq(s3c24xx_handle_irq);
 
 	return 0;
+
+out_free:
+	kfree(intc);
+out_domain_remove:
+	irq_domain_remove(domain);
+out_iounmap:
+	iounmap(reg_base);
 }
 
 static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = {
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 14/14] irqchip/xilinx-intc: Fix potential resource leak
  2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
                   ` (12 preceding siblings ...)
  2020-06-24  6:32 ` [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks Tiezhu Yang
@ 2020-06-24  6:32 ` Tiezhu Yang
  13 siblings, 0 replies; 17+ messages in thread
From: Tiezhu Yang @ 2020-06-24  6:32 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: linux-kernel, linux-mips, Xuefeng Li

There exists potential resource leak in the error path, fix it.

Fixes: 9689c99e4950 ("irqchip/xilinx: Add support for parent intc")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/irqchip/irq-xilinx-intc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index 1d3d273..dcc51e0 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -241,7 +241,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
 		} else {
 			pr_err("irq-xilinx: interrupts property not in DT\n");
 			ret = -EINVAL;
-			goto error;
+			goto error_domain_remove;
 		}
 	} else {
 		primary_intc = irqc;
@@ -250,6 +250,8 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
 
 	return 0;
 
+error_domain_remove:
+	irq_domain_remove(irqc->root_domain);
 error:
 	iounmap(irqc->base);
 	kfree(irqc);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks
  2020-06-24  6:32 ` [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks Tiezhu Yang
@ 2020-06-24 22:38   ` kernel test robot
  2020-06-25 14:17   ` kernel test robot
  1 sibling, 0 replies; 17+ messages in thread
From: kernel test robot @ 2020-06-24 22:38 UTC (permalink / raw)
  To: Tiezhu Yang, Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: kbuild-all, linux-kernel, linux-mips, Xuefeng Li

[-- Attachment #1: Type: text/plain, Size: 5573 bytes --]

Hi Tiezhu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.8-rc2 next-20200624]
[cannot apply to tip/irq/core omap/for-next xlnx/master arm-jcooper/irqchip/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tiezhu-Yang/irqchip-Fix-potential-resource-leaks/20200624-144653
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3e08a95294a4fb3702bb3d35ed08028433c37fe6
config: arm-randconfig-r012-20200624 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/irqchip/irq-s3c24xx.c:359:39: warning: no previous prototype for 's3c24xx_handle_irq' [-Wmissing-prototypes]
     359 | asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
         |                                       ^~~~~~~~~~~~~~~~~~
   drivers/irqchip/irq-s3c24xx.c:776:13: warning: no previous prototype for 's3c2412_init_irq' [-Wmissing-prototypes]
     776 | void __init s3c2412_init_irq(void)
         |             ^~~~~~~~~~~~~~~~
   drivers/irqchip/irq-s3c24xx.c:875:13: warning: no previous prototype for 's3c2416_init_irq' [-Wmissing-prototypes]
     875 | void __init s3c2416_init_irq(void)
         |             ^~~~~~~~~~~~~~~~
   drivers/irqchip/irq-s3c24xx.c:954:13: warning: no previous prototype for 's3c2440_init_irq' [-Wmissing-prototypes]
     954 | void __init s3c2440_init_irq(void)
         |             ^~~~~~~~~~~~~~~~
   drivers/irqchip/irq-s3c24xx.c: In function 's3c_init_intc_of':
>> drivers/irqchip/irq-s3c24xx.c:1242:3: error: 'ret' undeclared (first use in this function)
    1242 |   ret = -EINVAL;
         |   ^~~
   drivers/irqchip/irq-s3c24xx.c:1242:3: note: each undeclared identifier is reported only once for each function it appears in
   drivers/irqchip/irq-s3c24xx.c: At top level:
   drivers/irqchip/irq-s3c24xx.c:1311:12: warning: no previous prototype for 's3c2410_init_intc_of' [-Wmissing-prototypes]
    1311 | int __init s3c2410_init_intc_of(struct device_node *np,
         |            ^~~~~~~~~~~~~~~~~~~~
   drivers/irqchip/irq-s3c24xx.c:1333:12: warning: no previous prototype for 's3c2416_init_intc_of' [-Wmissing-prototypes]
    1333 | int __init s3c2416_init_intc_of(struct device_node *np,
         |            ^~~~~~~~~~~~~~~~~~~~
   drivers/irqchip/irq-s3c24xx.c: In function 's3c_init_intc_of':
>> drivers/irqchip/irq-s3c24xx.c:1298:1: warning: control reaches end of non-void function [-Wreturn-type]
    1298 | }
         | ^

vim +/ret +1242 drivers/irqchip/irq-s3c24xx.c

  1221	
  1222	static int __init s3c_init_intc_of(struct device_node *np,
  1223				struct device_node *interrupt_parent,
  1224				struct s3c24xx_irq_of_ctrl *s3c_ctrl, int num_ctrl)
  1225	{
  1226		struct s3c_irq_intc *intc;
  1227		struct s3c24xx_irq_of_ctrl *ctrl;
  1228		struct irq_domain *domain;
  1229		void __iomem *reg_base;
  1230		int i;
  1231	
  1232		reg_base = of_iomap(np, 0);
  1233		if (!reg_base) {
  1234			pr_err("irq-s3c24xx: could not map irq registers\n");
  1235			return -EINVAL;
  1236		}
  1237	
  1238		domain = irq_domain_add_linear(np, num_ctrl * 32,
  1239							     &s3c24xx_irq_ops_of, NULL);
  1240		if (!domain) {
  1241			pr_err("irq: could not create irq-domain\n");
> 1242			ret = -EINVAL;
  1243			goto out_iounmap;
  1244		}
  1245	
  1246		for (i = 0; i < num_ctrl; i++) {
  1247			ctrl = &s3c_ctrl[i];
  1248	
  1249			pr_debug("irq: found controller %s\n", ctrl->name);
  1250	
  1251			intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL);
  1252			if (!intc) {
  1253				ret = -ENOMEM;
  1254				goto out_domain_remove;
  1255			}
  1256	
  1257			intc->domain = domain;
  1258			intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data),
  1259					     GFP_KERNEL);
  1260			if (!intc->irqs) {
  1261				ret = -ENOMEM;
  1262				goto out_free;
  1263			}
  1264	
  1265			if (ctrl->parent) {
  1266				intc->reg_pending = reg_base + ctrl->offset;
  1267				intc->reg_mask = reg_base + ctrl->offset + 0x4;
  1268	
  1269				if (*(ctrl->parent)) {
  1270					intc->parent = *(ctrl->parent);
  1271				} else {
  1272					pr_warn("irq: parent of %s missing\n",
  1273						ctrl->name);
  1274					kfree(intc->irqs);
  1275					kfree(intc);
  1276					continue;
  1277				}
  1278			} else {
  1279				intc->reg_pending = reg_base + ctrl->offset;
  1280				intc->reg_mask = reg_base + ctrl->offset + 0x08;
  1281				intc->reg_intpnd = reg_base + ctrl->offset + 0x10;
  1282			}
  1283	
  1284			s3c24xx_clear_intc(intc);
  1285			s3c_intc[i] = intc;
  1286		}
  1287	
  1288		set_handle_irq(s3c24xx_handle_irq);
  1289	
  1290		return 0;
  1291	
  1292	out_free:
  1293		kfree(intc);
  1294	out_domain_remove:
  1295		irq_domain_remove(domain);
  1296	out_iounmap:
  1297		iounmap(reg_base);
> 1298	}
  1299	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28900 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks
  2020-06-24  6:32 ` [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks Tiezhu Yang
  2020-06-24 22:38   ` kernel test robot
@ 2020-06-25 14:17   ` kernel test robot
  1 sibling, 0 replies; 17+ messages in thread
From: kernel test robot @ 2020-06-25 14:17 UTC (permalink / raw)
  To: Tiezhu Yang, Thomas Gleixner, Jason Cooper, Marc Zyngier
  Cc: kbuild-all, clang-built-linux, linux-kernel, linux-mips, Xuefeng Li

[-- Attachment #1: Type: text/plain, Size: 15287 bytes --]

Hi Tiezhu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.8-rc2 next-20200624]
[cannot apply to tip/irq/core omap/for-next xlnx/master arm-jcooper/irqchip/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tiezhu-Yang/irqchip-Fix-potential-resource-leaks/20200624-144653
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3e08a95294a4fb3702bb3d35ed08028433c37fe6
config: arm-randconfig-r035-20200624 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 1d4c87335d5236ea1f35937e1014980ba961ae34)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/arm/include/asm/io.h:438:
   include/asm-generic/io.h:676:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           insl(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:206:34: note: expanded from macro 'insl'
   #define insl(p,d,l)     __raw_readsl(__ioaddr(p),d,l)
                                        ^~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:202:65: note: expanded from macro '__ioaddr'
   #define __ioaddr(p)     (__builtin_constant_p((p)) ? __ioaddr(p)  : __ioaddrc(p))
                                                                       ^~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:194:86: note: expanded from macro '__ioaddrc'
   #define __ioaddrc(port) ((__PORT_PCIO(port) ? PCIO_BASE + (port) : (void __iomem *)0 + (port)))
                                                                      ~~~~~~~~~~~~~~~~~ ^
   In file included from drivers/irqchip/irq-s3c24xx.c:13:
   In file included from include/linux/io.h:13:
   In file included from arch/arm/include/asm/io.h:438:
   include/asm-generic/io.h:685:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outsb(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:208:36: note: expanded from macro 'outsb'
   #define outsb(p,d,l)    __raw_writesb(__ioaddr(p),d,l)
                                         ^~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:202:65: note: expanded from macro '__ioaddr'
   #define __ioaddr(p)     (__builtin_constant_p((p)) ? __ioaddr(p)  : __ioaddrc(p))
                                                                       ^~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:194:86: note: expanded from macro '__ioaddrc'
   #define __ioaddrc(port) ((__PORT_PCIO(port) ? PCIO_BASE + (port) : (void __iomem *)0 + (port)))
                                                                      ~~~~~~~~~~~~~~~~~ ^
   In file included from drivers/irqchip/irq-s3c24xx.c:13:
   In file included from include/linux/io.h:13:
   In file included from arch/arm/include/asm/io.h:438:
   include/asm-generic/io.h:694:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outsw(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:209:36: note: expanded from macro 'outsw'
   #define outsw(p,d,l)    __raw_writesw(__ioaddr(p),d,l)
                                         ^~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:202:65: note: expanded from macro '__ioaddr'
   #define __ioaddr(p)     (__builtin_constant_p((p)) ? __ioaddr(p)  : __ioaddrc(p))
                                                                       ^~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:194:86: note: expanded from macro '__ioaddrc'
   #define __ioaddrc(port) ((__PORT_PCIO(port) ? PCIO_BASE + (port) : (void __iomem *)0 + (port)))
                                                                      ~~~~~~~~~~~~~~~~~ ^
   In file included from drivers/irqchip/irq-s3c24xx.c:13:
   In file included from include/linux/io.h:13:
   In file included from arch/arm/include/asm/io.h:438:
   include/asm-generic/io.h:703:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outsl(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:210:36: note: expanded from macro 'outsl'
   #define outsl(p,d,l)    __raw_writesl(__ioaddr(p),d,l)
                                         ^~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:202:65: note: expanded from macro '__ioaddr'
   #define __ioaddr(p)     (__builtin_constant_p((p)) ? __ioaddr(p)  : __ioaddrc(p))
                                                                       ^~~~~~~~~~~~
   arch/arm/mach-s3c24xx/include/mach/io.h:194:86: note: expanded from macro '__ioaddrc'
   #define __ioaddrc(port) ((__PORT_PCIO(port) ? PCIO_BASE + (port) : (void __iomem *)0 + (port)))
                                                                      ~~~~~~~~~~~~~~~~~ ^
   drivers/irqchip/irq-s3c24xx.c:359:39: warning: no previous prototype for function 's3c24xx_handle_irq' [-Wmissing-prototypes]
   asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
                                         ^
   drivers/irqchip/irq-s3c24xx.c:359:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
              ^
              static 
   drivers/irqchip/irq-s3c24xx.c:676:13: warning: no previous prototype for function 's3c2410_init_irq' [-Wmissing-prototypes]
   void __init s3c2410_init_irq(void)
               ^
   drivers/irqchip/irq-s3c24xx.c:676:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2410_init_irq(void)
   ^
   static 
   drivers/irqchip/irq-s3c24xx.c:776:13: warning: no previous prototype for function 's3c2412_init_irq' [-Wmissing-prototypes]
   void __init s3c2412_init_irq(void)
               ^
   drivers/irqchip/irq-s3c24xx.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2412_init_irq(void)
   ^
   static 
   drivers/irqchip/irq-s3c24xx.c:875:13: warning: no previous prototype for function 's3c2416_init_irq' [-Wmissing-prototypes]
   void __init s3c2416_init_irq(void)
               ^
   drivers/irqchip/irq-s3c24xx.c:875:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2416_init_irq(void)
   ^
   static 
   drivers/irqchip/irq-s3c24xx.c:954:13: warning: no previous prototype for function 's3c2440_init_irq' [-Wmissing-prototypes]
   void __init s3c2440_init_irq(void)
               ^
   drivers/irqchip/irq-s3c24xx.c:954:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2440_init_irq(void)
   ^
   static 
   drivers/irqchip/irq-s3c24xx.c:1117:13: warning: no previous prototype for function 's3c2443_init_irq' [-Wmissing-prototypes]
   void __init s3c2443_init_irq(void)
               ^
   drivers/irqchip/irq-s3c24xx.c:1117:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2443_init_irq(void)
   ^
   static 
>> drivers/irqchip/irq-s3c24xx.c:1242:3: error: use of undeclared identifier 'ret'
                   ret = -EINVAL;
                   ^
   drivers/irqchip/irq-s3c24xx.c:1253:4: error: use of undeclared identifier 'ret'
                           ret = -ENOMEM;
                           ^
   drivers/irqchip/irq-s3c24xx.c:1261:4: error: use of undeclared identifier 'ret'
                           ret = -ENOMEM;
                           ^
   drivers/irqchip/irq-s3c24xx.c:1311:12: warning: no previous prototype for function 's3c2410_init_intc_of' [-Wmissing-prototypes]
   int __init s3c2410_init_intc_of(struct device_node *np,
              ^
   drivers/irqchip/irq-s3c24xx.c:1311:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int __init s3c2410_init_intc_of(struct device_node *np,
   ^
   static 
   drivers/irqchip/irq-s3c24xx.c:1333:12: warning: no previous prototype for function 's3c2416_init_intc_of' [-Wmissing-prototypes]
   int __init s3c2416_init_intc_of(struct device_node *np,
              ^
   drivers/irqchip/irq-s3c24xx.c:1333:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int __init s3c2416_init_intc_of(struct device_node *np,
   ^
   static 
   14 warnings and 3 errors generated.

vim +/ret +1242 drivers/irqchip/irq-s3c24xx.c

  1116	
> 1117	void __init s3c2443_init_irq(void)
  1118	{
  1119		pr_info("S3C2443: IRQ Support\n");
  1120	
  1121	#ifdef CONFIG_FIQ
  1122		init_FIQ(FIQ_START);
  1123	#endif
  1124	
  1125		s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2443base[0], NULL,
  1126						0x4a000000);
  1127		if (IS_ERR(s3c_intc[0])) {
  1128			pr_err("irq: could not create main interrupt controller\n");
  1129			return;
  1130		}
  1131	
  1132		s3c24xx_init_intc(NULL, &init_eint[0], s3c_intc[0], 0x560000a4);
  1133		s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2443subint[0],
  1134						s3c_intc[0], 0x4a000018);
  1135	}
  1136	#endif
  1137	
  1138	#ifdef CONFIG_OF
  1139	static int s3c24xx_irq_map_of(struct irq_domain *h, unsigned int virq,
  1140								irq_hw_number_t hw)
  1141	{
  1142		unsigned int ctrl_num = hw / 32;
  1143		unsigned int intc_hw = hw % 32;
  1144		struct s3c_irq_intc *intc = s3c_intc[ctrl_num];
  1145		struct s3c_irq_intc *parent_intc = intc->parent;
  1146		struct s3c_irq_data *irq_data = &intc->irqs[intc_hw];
  1147	
  1148		/* attach controller pointer to irq_data */
  1149		irq_data->intc = intc;
  1150		irq_data->offset = intc_hw;
  1151	
  1152		if (!parent_intc)
  1153			irq_set_chip_and_handler(virq, &s3c_irq_chip, handle_edge_irq);
  1154		else
  1155			irq_set_chip_and_handler(virq, &s3c_irq_level_chip,
  1156						 handle_edge_irq);
  1157	
  1158		irq_set_chip_data(virq, irq_data);
  1159	
  1160		return 0;
  1161	}
  1162	
  1163	/* Translate our of irq notation
  1164	 * format: <ctrl_num ctrl_irq parent_irq type>
  1165	 */
  1166	static int s3c24xx_irq_xlate_of(struct irq_domain *d, struct device_node *n,
  1167				const u32 *intspec, unsigned int intsize,
  1168				irq_hw_number_t *out_hwirq, unsigned int *out_type)
  1169	{
  1170		struct s3c_irq_intc *intc;
  1171		struct s3c_irq_intc *parent_intc;
  1172		struct s3c_irq_data *irq_data;
  1173		struct s3c_irq_data *parent_irq_data;
  1174		int irqno;
  1175	
  1176		if (WARN_ON(intsize < 4))
  1177			return -EINVAL;
  1178	
  1179		if (intspec[0] > 2 || !s3c_intc[intspec[0]]) {
  1180			pr_err("controller number %d invalid\n", intspec[0]);
  1181			return -EINVAL;
  1182		}
  1183		intc = s3c_intc[intspec[0]];
  1184	
  1185		*out_hwirq = intspec[0] * 32 + intspec[2];
  1186		*out_type = intspec[3] & IRQ_TYPE_SENSE_MASK;
  1187	
  1188		parent_intc = intc->parent;
  1189		if (parent_intc) {
  1190			irq_data = &intc->irqs[intspec[2]];
  1191			irq_data->parent_irq = intspec[1];
  1192			parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
  1193			parent_irq_data->sub_intc = intc;
  1194			parent_irq_data->sub_bits |= (1UL << intspec[2]);
  1195	
  1196			/* parent_intc is always s3c_intc[0], so no offset */
  1197			irqno = irq_create_mapping(parent_intc->domain, intspec[1]);
  1198			if (irqno < 0) {
  1199				pr_err("irq: could not map parent interrupt\n");
  1200				return irqno;
  1201			}
  1202	
  1203			irq_set_chained_handler(irqno, s3c_irq_demux);
  1204		}
  1205	
  1206		return 0;
  1207	}
  1208	
  1209	static const struct irq_domain_ops s3c24xx_irq_ops_of = {
  1210		.map = s3c24xx_irq_map_of,
  1211		.xlate = s3c24xx_irq_xlate_of,
  1212	};
  1213	
  1214	struct s3c24xx_irq_of_ctrl {
  1215		char			*name;
  1216		unsigned long		offset;
  1217		struct s3c_irq_intc	**handle;
  1218		struct s3c_irq_intc	**parent;
  1219		struct irq_domain_ops	*ops;
  1220	};
  1221	
  1222	static int __init s3c_init_intc_of(struct device_node *np,
  1223				struct device_node *interrupt_parent,
  1224				struct s3c24xx_irq_of_ctrl *s3c_ctrl, int num_ctrl)
  1225	{
  1226		struct s3c_irq_intc *intc;
  1227		struct s3c24xx_irq_of_ctrl *ctrl;
  1228		struct irq_domain *domain;
  1229		void __iomem *reg_base;
  1230		int i;
  1231	
  1232		reg_base = of_iomap(np, 0);
  1233		if (!reg_base) {
  1234			pr_err("irq-s3c24xx: could not map irq registers\n");
  1235			return -EINVAL;
  1236		}
  1237	
  1238		domain = irq_domain_add_linear(np, num_ctrl * 32,
  1239							     &s3c24xx_irq_ops_of, NULL);
  1240		if (!domain) {
  1241			pr_err("irq: could not create irq-domain\n");
> 1242			ret = -EINVAL;
  1243			goto out_iounmap;
  1244		}
  1245	
  1246		for (i = 0; i < num_ctrl; i++) {
  1247			ctrl = &s3c_ctrl[i];
  1248	
  1249			pr_debug("irq: found controller %s\n", ctrl->name);
  1250	
  1251			intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL);
  1252			if (!intc) {
  1253				ret = -ENOMEM;
  1254				goto out_domain_remove;
  1255			}
  1256	
  1257			intc->domain = domain;
  1258			intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data),
  1259					     GFP_KERNEL);
  1260			if (!intc->irqs) {
  1261				ret = -ENOMEM;
  1262				goto out_free;
  1263			}
  1264	
  1265			if (ctrl->parent) {
  1266				intc->reg_pending = reg_base + ctrl->offset;
  1267				intc->reg_mask = reg_base + ctrl->offset + 0x4;
  1268	
  1269				if (*(ctrl->parent)) {
  1270					intc->parent = *(ctrl->parent);
  1271				} else {
  1272					pr_warn("irq: parent of %s missing\n",
  1273						ctrl->name);
  1274					kfree(intc->irqs);
  1275					kfree(intc);
  1276					continue;
  1277				}
  1278			} else {
  1279				intc->reg_pending = reg_base + ctrl->offset;
  1280				intc->reg_mask = reg_base + ctrl->offset + 0x08;
  1281				intc->reg_intpnd = reg_base + ctrl->offset + 0x10;
  1282			}
  1283	
  1284			s3c24xx_clear_intc(intc);
  1285			s3c_intc[i] = intc;
  1286		}
  1287	
  1288		set_handle_irq(s3c24xx_handle_irq);
  1289	
  1290		return 0;
  1291	
  1292	out_free:
  1293		kfree(intc);
  1294	out_domain_remove:
  1295		irq_domain_remove(domain);
  1296	out_iounmap:
  1297		iounmap(reg_base);
  1298	}
  1299	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32189 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-06-25 14:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24  6:32 [PATCH v2 00/14] irqchip: Fix potential resource leaks Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 01/14] irqchip/ath79-misc: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 02/14] irqchip/csky-apb-intc: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 03/14] irqchip/csky-mpintc: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 04/14] irqchip/davinci-aintc: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 05/14] irqchip/davinci-cp-intc: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 06/14] irqchip/digicolor: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 07/14] irqchip/dw-apb-ictl: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 08/14] irqchip/ls1x: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 09/14] irqchip/mscc-ocelot: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 10/14] irqchip/nvic: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 11/14] irqchip/omap-intc: Fix potential resource leak Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 12/14] irqchip/riscv-intc: " Tiezhu Yang
2020-06-24  6:32 ` [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks Tiezhu Yang
2020-06-24 22:38   ` kernel test robot
2020-06-25 14:17   ` kernel test robot
2020-06-24  6:32 ` [PATCH v2 14/14] irqchip/xilinx-intc: Fix potential resource leak Tiezhu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).