Skip to content

Commit 533bec1

Browse files
YuuoniyStefano Stabellini
authored andcommitted
arm/xen: Fix some refcount leaks
The of_find_compatible_node() function returns a node pointer with refcount incremented, We should use of_node_put() on it when done Add the missing of_node_put() to release the refcount. Fixes: 9b08aaa ("ARM: XEN: Move xen_early_init() before efi_init()") Fixes: b237158 ("arm/xen: Read extended regions from DT and init Xen resource") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
1 parent f31076a commit 533bec1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/arm/xen/enlighten.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,15 @@ int __init arch_xen_unpopulated_init(struct resource **res)
337337

338338
if (!nr_reg) {
339339
pr_err("No extended regions are found\n");
340+
of_node_put(np);
340341
return -EINVAL;
341342
}
342343

343344
regs = kcalloc(nr_reg, sizeof(*regs), GFP_KERNEL);
344-
if (!regs)
345+
if (!regs) {
346+
of_node_put(np);
345347
return -ENOMEM;
348+
}
346349

347350
/*
348351
* Create resource from extended regions provided by the hypervisor to be
@@ -403,8 +406,8 @@ int __init arch_xen_unpopulated_init(struct resource **res)
403406
*res = &xen_resource;
404407

405408
err:
409+
of_node_put(np);
406410
kfree(regs);
407-
408411
return rc;
409412
}
410413
#endif
@@ -424,8 +427,10 @@ static void __init xen_dt_guest_init(void)
424427

425428
if (of_address_to_resource(xen_node, GRANT_TABLE_INDEX, &res)) {
426429
pr_err("Xen grant table region is not found\n");
430+
of_node_put(xen_node);
427431
return;
428432
}
433+
of_node_put(xen_node);
429434
xen_grant_frames = res.start;
430435
}
431436

0 commit comments

Comments
 (0)