Skip to content

Commit 5f856d7

Browse files
Yuan Canvireshk
authored andcommitted
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: f8ede0f ("MIPS: Loongson 2F: Add CPU frequency scaling support") Signed-off-by: Yuan Can <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 41baf66 commit 5f856d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/cpufreq/loongson2_cpufreq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ static int __init cpufreq_init(void)
148148

149149
ret = cpufreq_register_driver(&loongson2_cpufreq_driver);
150150

151-
if (!ret && !nowait) {
151+
if (ret) {
152+
platform_driver_unregister(&platform_driver);
153+
} else if (!nowait) {
152154
saved_cpu_wait = cpu_wait;
153155
cpu_wait = loongson2_cpu_wait;
154156
}

0 commit comments

Comments
 (0)