* [PATCH v3] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init
@ 2024-08-20 9:28 Ma Ke
2024-08-20 9:54 ` Marc Zyngier
2024-08-20 15:12 ` [tip: irq/urgent] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init() tip-bot2 for Ma Ke
0 siblings, 2 replies; 3+ messages in thread
From: Ma Ke @ 2024-08-20 9:28 UTC (permalink / raw)
To: maz, tglx, Suravee.Suthikulpanit, akpm
Cc: linux-arm-kernel, linux-kernel, Ma Ke, stable
We fail to perform an of_node_put() when of_address_to_resource()
fails, leading to a refcount leak.
Address this by moving the error handling path outside of the loop and
making it common to all failure modes.
Cc: stable@vger.kernel.org
Fixes: 4266ab1a8ff5 ("irqchip/gic-v2m: Refactor to prepare for ACPI support")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
Changes in v3:
- modified the description information. Changed the added 'put' function
to 'of_node_put' (the previous incorrect function was 'of_put_node').
Changes in v2:
- modified the patch according to suggestions.
---
drivers/irqchip/irq-gic-v2m.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 51af63c046ed..be35c5349986 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -407,12 +407,12 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis,
&res, 0);
- if (ret) {
- of_node_put(child);
+ if (ret)
break;
- }
}
+ if (ret && child)
+ of_node_put(child);
if (!ret)
ret = gicv2m_allocate_domains(parent);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init
2024-08-20 9:28 [PATCH v3] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init Ma Ke
@ 2024-08-20 9:54 ` Marc Zyngier
2024-08-20 15:12 ` [tip: irq/urgent] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init() tip-bot2 for Ma Ke
1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2024-08-20 9:54 UTC (permalink / raw)
To: Ma Ke
Cc: tglx, Suravee.Suthikulpanit, akpm, linux-arm-kernel, linux-kernel,
stable
On Tue, 20 Aug 2024 10:28:43 +0100,
Ma Ke <make24@iscas.ac.cn> wrote:
>
> We fail to perform an of_node_put() when of_address_to_resource()
> fails, leading to a refcount leak.
>
> Address this by moving the error handling path outside of the loop and
> making it common to all failure modes.
>
> Cc: stable@vger.kernel.org
> Fixes: 4266ab1a8ff5 ("irqchip/gic-v2m: Refactor to prepare for ACPI support")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: irq/urgent] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init()
2024-08-20 9:28 [PATCH v3] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init Ma Ke
2024-08-20 9:54 ` Marc Zyngier
@ 2024-08-20 15:12 ` tip-bot2 for Ma Ke
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Ma Ke @ 2024-08-20 15:12 UTC (permalink / raw)
To: linux-tip-commits
Cc: Ma Ke, Thomas Gleixner, Marc Zyngier, stable, x86, linux-kernel
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: c5af2c90ba5629f0424a8d315f75fb8d91713c3c
Gitweb: https://git.kernel.org/tip/c5af2c90ba5629f0424a8d315f75fb8d91713c3c
Author: Ma Ke <make24@iscas.ac.cn>
AuthorDate: Tue, 20 Aug 2024 17:28:43 +08:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 20 Aug 2024 17:05:32 +02:00
irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init()
gicv2m_of_init() fails to perform an of_node_put() when
of_address_to_resource() fails, leading to a refcount leak.
Address this by moving the error handling path outside of the loop and
making it common to all failure modes.
Fixes: 4266ab1a8ff5 ("irqchip/gic-v2m: Refactor to prepare for ACPI support")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20240820092843.1219933-1-make24@iscas.ac.cn
---
drivers/irqchip/irq-gic-v2m.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 51af63c..be35c53 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -407,12 +407,12 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis,
&res, 0);
- if (ret) {
- of_node_put(child);
+ if (ret)
break;
- }
}
+ if (ret && child)
+ of_node_put(child);
if (!ret)
ret = gicv2m_allocate_domains(parent);
if (ret)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-20 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 9:28 [PATCH v3] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init Ma Ke
2024-08-20 9:54 ` Marc Zyngier
2024-08-20 15:12 ` [tip: irq/urgent] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init() tip-bot2 for Ma Ke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.