Message ID | 1555469093-35179-3-git-send-email-wen.yang99@zte.com.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] firmware: arm_sdei: fix leaked of_node references | expand |
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);
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(-)