* [PATCH 1/3] irqchip/gic-v3: add of_node_put() when finish using the device node
@ 2022-05-09 6:32 Yang Yingliang
2022-05-09 6:32 ` [PATCH 2/3] irqchip/gic-v3: fix missing of_node_put() in gic_populate_ppi_part() Yang Yingliang
2022-05-09 6:32 ` [PATCH 3/3] irqchip/gic-v3: fix possible memory leak " Yang Yingliang
0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-05-09 6:32 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel; +Cc: tglx, maz
of_find_node_by_phandle() returns a node pointer with refcount
incremented, use of_node_put() on it when done.
Fixes: e3825ba1af3a ("irqchip/gic-v3: Add support for partitioned PPIs")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/irqchip/irq-gic-v3.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index b252d5534547..fda39adc7cd6 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -1597,6 +1597,7 @@ static int partition_domain_translate(struct irq_domain *d,
ppi_idx = __gic_get_ppi_index(ppi_intid);
ret = partition_translate_id(gic_data.ppi_descs[ppi_idx],
of_node_to_fwnode(np));
+ of_node_put(np);
if (ret < 0)
return ret;
@@ -1906,12 +1907,15 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
continue;
cpu = of_cpu_node_to_id(cpu_node);
- if (WARN_ON(cpu < 0))
+ if (WARN_ON(cpu < 0)) {
+ of_node_put(cpu_node);
continue;
+ }
pr_cont("%pOF[%d] ", cpu_node, cpu);
cpumask_set_cpu(cpu, &part->mask);
+ of_node_put(cpu_node);
}
pr_cont("}\n");
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] irqchip/gic-v3: fix missing of_node_put() in gic_populate_ppi_part()
2022-05-09 6:32 [PATCH 1/3] irqchip/gic-v3: add of_node_put() when finish using the device node Yang Yingliang
@ 2022-05-09 6:32 ` Yang Yingliang
2022-05-09 6:32 ` [PATCH 3/3] irqchip/gic-v3: fix possible memory leak " Yang Yingliang
1 sibling, 0 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-05-09 6:32 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel; +Cc: tglx, maz
If kcalloc() fails, refcount of 'parts_node' should be decreased.
Fixes: 52085d3f2028 ("irqchip/gic-v3: Dynamically allocate PPI partition descriptors")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/irqchip/irq-gic-v3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index fda39adc7cd6..0e23dc8bafcf 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -1866,7 +1866,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
gic_data.ppi_descs = kcalloc(gic_data.ppi_nr, sizeof(*gic_data.ppi_descs), GFP_KERNEL);
if (!gic_data.ppi_descs)
- return;
+ goto out_put_node;
nr_parts = of_get_child_count(parts_node);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] irqchip/gic-v3: fix possible memory leak in gic_populate_ppi_part()
2022-05-09 6:32 [PATCH 1/3] irqchip/gic-v3: add of_node_put() when finish using the device node Yang Yingliang
2022-05-09 6:32 ` [PATCH 2/3] irqchip/gic-v3: fix missing of_node_put() in gic_populate_ppi_part() Yang Yingliang
@ 2022-05-09 6:32 ` Yang Yingliang
1 sibling, 0 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-05-09 6:32 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel; +Cc: tglx, maz
'ppi_descs' should be freed in error path in gic_populate_ppi_part().
Fixes: 52085d3f2028 ("irqchip/gic-v3: Dynamically allocate PPI partition descriptors")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/irqchip/irq-gic-v3.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 0e23dc8bafcf..3264fef89360 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -1871,11 +1871,11 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
nr_parts = of_get_child_count(parts_node);
if (!nr_parts)
- goto out_put_node;
+ goto out_free_ppi_descs;
parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
if (WARN_ON(!parts))
- goto out_put_node;
+ goto out_free_ppi_descs;
for_each_child_of_node(parts_node, child_part) {
struct partition_affinity *part;
@@ -1946,6 +1946,9 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
gic_data.ppi_descs[i] = desc;
}
+out_free_ppi_descs:
+ kfree(gic_data.ppi_descs);
+ gic_data.ppi_descs = NULL;
out_put_node:
of_node_put(parts_node);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-09 6:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 6:32 [PATCH 1/3] irqchip/gic-v3: add of_node_put() when finish using the device node Yang Yingliang
2022-05-09 6:32 ` [PATCH 2/3] irqchip/gic-v3: fix missing of_node_put() in gic_populate_ppi_part() Yang Yingliang
2022-05-09 6:32 ` [PATCH 3/3] irqchip/gic-v3: fix possible memory leak " Yang Yingliang
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).