irqchip/gic-v3: add of_node_put() when finish using the device node
Subsystems (2)
PATCH 1/3 irqchip/gic-v3: add of_node_put() when finish using the device node
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 <[email protected]>
Signed-off-by Yang Yingliang <[email protected]>
--- drivers/irqchip/irq-gic-v3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +5 -1
@@ -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" );
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/3 irqchip/gic-v3: fix missing of_node_put() in gic_populate_ppi_part()
If kcalloc() fails, refcount of 'parts_node' should be decreased.
Fixes 52085d3f2028 ("irqchip/gic-v3: Dynamically allocate PPI partition descriptors")
Reported-by Hulk Robot <[email protected]>
Signed-off-by Yang Yingliang <[email protected]>
--- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +1 -1
@@ -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);
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/3 irqchip/gic-v3: fix possible memory leak in gic_populate_ppi_part()
In reply to Yang Yingliang'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 <[email protected]>
--- drivers/irqchip/irq-gic-v3.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3.c +5 -2
@@ -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); }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel