Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: loongson2: Unregister platform_driver on failure

When cpufreq_register_driver() returns error, the cpufreq_init() returns
without unregister platform_driver, fix by add missing
platform_driver_unregister() when cpufreq_register_driver() failed.

Fixes: f8ede0f700f5 ("MIPS: Loongson 2F: Add CPU frequency scaling support")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

authored by

Yuan Can and committed by
Viresh Kumar
5f856d71 41baf662

+3 -1
+3 -1
drivers/cpufreq/loongson2_cpufreq.c
··· 148 148 149 149 ret = cpufreq_register_driver(&loongson2_cpufreq_driver); 150 150 151 - if (!ret && !nowait) { 151 + if (ret) { 152 + platform_driver_unregister(&platform_driver); 153 + } else if (!nowait) { 152 154 saved_cpu_wait = cpu_wait; 153 155 cpu_wait = loongson2_cpu_wait; 154 156 }