Messages in this thread Patch in this message | | | From | Wen Yang <> | Subject | [PATCH 2/3] firmware: psci: fix leaked of_node references | Date | Wed, 17 Apr 2019 10:44:52 +0800 |
| |
The call to of_find_matching_node_and_match returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
672 int __init psci_dt_init(void) 673 { 674 struct device_node *np; ... 678 np = of_find_matching_node_and_match(...); 679 680 if (!np || !of_device_is_available(np)) 682 return -ENODEV; ---> leaked here ... 686 return init_fn(np); ---> released here 687 }
Detected by using coccinelle.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/firmware/psci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index c80ec1d..e4143f8 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -677,8 +677,10 @@ int __init psci_dt_init(void) np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); - if (!np || !of_device_is_available(np)) + if (!np || !of_device_is_available(np)) { + of_node_put(np); return -ENODEV; + } init_fn = (psci_initcall_t)matched_np->data; return init_fn(np); -- 2.9.5
| |