Skip to content

Commit 53effce

Browse files
committed
Merge: Updates for powerpc XIVE
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6497 Description: Updates for powerpc XIVE JIRA: https://issues.redhat.com/browse/RHEL-80849 CVE: CVE-2022-49437 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=66839686 Tested: Verified Brew build test kernel RPMs Signed-off-by: Mamatha Inamdar <[email protected]> Approved-by: Steve Best <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents e352bd7 + 2297339 commit 53effce

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

arch/powerpc/sysdev/xive/spapr.c

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ static int xive_irq_bitmap_add(int base, int count)
6969
return 0;
7070
}
7171

72+
static void xive_irq_bitmap_remove_all(void)
73+
{
74+
struct xive_irq_bitmap *xibm, *tmp;
75+
76+
list_for_each_entry_safe(xibm, tmp, &xive_irq_bitmaps, list) {
77+
list_del(&xibm->list);
78+
kfree(xibm->bitmap);
79+
kfree(xibm);
80+
}
81+
}
82+
7283
static int __xive_irq_bitmap_alloc(struct xive_irq_bitmap *xibm)
7384
{
7485
int irq;
@@ -802,7 +813,7 @@ bool __init xive_spapr_init(void)
802813
u32 val;
803814
u32 len;
804815
const __be32 *reg;
805-
int i;
816+
int i, err;
806817

807818
if (xive_spapr_disabled())
808819
return false;
@@ -818,32 +829,35 @@ bool __init xive_spapr_init(void)
818829
/* Resource 1 is the OS ring TIMA */
819830
if (of_address_to_resource(np, 1, &r)) {
820831
pr_err("Failed to get thread mgmnt area resource\n");
821-
return false;
832+
goto err_put;
822833
}
823834
tima = ioremap(r.start, resource_size(&r));
824835
if (!tima) {
825836
pr_err("Failed to map thread mgmnt area\n");
826-
return false;
837+
goto err_put;
827838
}
828839

829840
if (!xive_get_max_prio(&max_prio))
830-
return false;
841+
goto err_unmap;
831842

832843
/* Feed the IRQ number allocator with the ranges given in the DT */
833844
reg = of_get_property(np, "ibm,xive-lisn-ranges", &len);
834845
if (!reg) {
835846
pr_err("Failed to read 'ibm,xive-lisn-ranges' property\n");
836-
return false;
847+
goto err_unmap;
837848
}
838849

839850
if (len % (2 * sizeof(u32)) != 0) {
840851
pr_err("invalid 'ibm,xive-lisn-ranges' property\n");
841-
return false;
852+
goto err_unmap;
842853
}
843854

844-
for (i = 0; i < len / (2 * sizeof(u32)); i++, reg += 2)
845-
xive_irq_bitmap_add(be32_to_cpu(reg[0]),
846-
be32_to_cpu(reg[1]));
855+
for (i = 0; i < len / (2 * sizeof(u32)); i++, reg += 2) {
856+
err = xive_irq_bitmap_add(be32_to_cpu(reg[0]),
857+
be32_to_cpu(reg[1]));
858+
if (err < 0)
859+
goto err_mem_free;
860+
}
847861

848862
/* Iterate the EQ sizes and pick one */
849863
of_property_for_each_u32(np, "ibm,xive-eq-sizes", prop, reg, val) {
@@ -854,10 +868,19 @@ bool __init xive_spapr_init(void)
854868

855869
/* Initialize XIVE core with our backend */
856870
if (!xive_core_init(np, &xive_spapr_ops, tima, TM_QW1_OS, max_prio))
857-
return false;
871+
goto err_mem_free;
858872

873+
of_node_put(np);
859874
pr_info("Using %dkB queues\n", 1 << (xive_queue_shift - 10));
860875
return true;
876+
877+
err_mem_free:
878+
xive_irq_bitmap_remove_all();
879+
err_unmap:
880+
iounmap(tima);
881+
err_put:
882+
of_node_put(np);
883+
return false;
861884
}
862885

863886
machine_arch_initcall(pseries, xive_core_debug_init);

0 commit comments

Comments
 (0)