diff mbox series

[4.4.y-cip,05/11] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path

Message ID 20200909044233.4115-6-wens@csie.org (mailing list archive)
State Accepted
Delegated to: Nobuhiro Iwamatsu
Headers show
Series ti-cpufreq backport | expand

Commit Message

Chen-Yu Tsai Sept. 9, 2020, 4:42 a.m. UTC
From: Christophe Jaillet <christophe.jaillet@wanadoo.fr>

commit 9a6e91d08e7707baa2f824257342ca7efcb199bc upstream.

If 'dev_pm_opp_set_supported_hw()' fails, 'opp_data->opp_node' refcount
will be decremented 2 times.
One, just a few lines above, and another one in the error handling path.

Fix it by simply moving the 'of_node_put' call of the normal path.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Chen-Yu Tsai (Moxa) <wens@csie.org>
 drivers/cpufreq/ti-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 7ff7ae3c3911c..1c63e96cba1f2 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -245,8 +245,6 @@  static int ti_cpufreq_init(void)
 	if (ret)
 		goto fail_put_node;
-	of_node_put(opp_data->opp_node);
 	ret = PTR_ERR_OR_ZERO(dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
 							  version, VERSION_COUNT));
 	if (ret) {
@@ -255,6 +253,8 @@  static int ti_cpufreq_init(void)
 		goto fail_put_node;
+	of_node_put(opp_data->opp_node);
 	platform_device_register_simple("cpufreq-dt", -1, NULL, 0);