[PATCH 5.0 105/146] cpufreq: scpi: Fix use after free
From: Greg Kroah-Hartman
Date: Mon Apr 01 2019 - 13:09:35 EST
5.0-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Stehlà <vincent.stehle@xxxxxxxxxxx>
commit 31d4c528cea4023cf36f6148c03bb960cedefeef upstream.
Free the priv structure only after we are done using it.
Fixes: 1690d8bb91e370ab ("cpufreq: scpi/scmi: Fix freeing of dynamic OPPs")
Signed-off-by: Vincent Stehlà <vincent.stehle@xxxxxxxxxxx>
Cc: 4.20+ <stable@xxxxxxxxxxxxxxx> # 4.20+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/cpufreq/scpi-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -189,8 +189,8 @@ static int scpi_cpufreq_exit(struct cpuf
cpufreq_cooling_unregister(priv->cdev);
clk_put(priv->clk);
dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
- kfree(priv);
dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
+ kfree(priv);
return 0;
}