Message ID | 20241030-cpuidle-qcom-spm-cleanup-v1-1-04416fcca7de@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | cpuidle: qcom-spm: fix resource release in spm_cpuidle_register | expand |
On Wed, Oct 30, 2024 at 07:38:32AM +0100, Javier Carrasco wrote: > If of_find_device_by_node() fails, its error path does not include a > call to of_node_put(cpu_node), which has been successfully acquired at > this point. > > Move the existing of_node_put(cpu_node) to the point where cpu_node is > no longer required, covering all code paths and avoiding leaking the > resource in any case. > > Cc: stable@vger.kernel.org > Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM handling") > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> > --- > drivers/cpuidle/cpuidle-qcom-spm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
diff --git a/drivers/cpuidle/cpuidle-qcom-spm.c b/drivers/cpuidle/cpuidle-qcom-spm.c index 3ab240e0e122..c9ab49b310fd 100644 --- a/drivers/cpuidle/cpuidle-qcom-spm.c +++ b/drivers/cpuidle/cpuidle-qcom-spm.c @@ -96,12 +96,12 @@ static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu) return -ENODEV; saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0); + of_node_put(cpu_node); if (!saw_node) return -ENODEV; pdev = of_find_device_by_node(saw_node); of_node_put(saw_node); - of_node_put(cpu_node); if (!pdev) return -ENODEV;
If of_find_device_by_node() fails, its error path does not include a call to of_node_put(cpu_node), which has been successfully acquired at this point. Move the existing of_node_put(cpu_node) to the point where cpu_node is no longer required, covering all code paths and avoiding leaking the resource in any case. Cc: stable@vger.kernel.org Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM handling") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- drivers/cpuidle/cpuidle-qcom-spm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)