Skip to content

Commit b2073db

Browse files
Yuan Cangregkh
authored andcommitted
cpufreq: loongson2: Unregister platform_driver on failure
[ Upstream commit 5f856d7 ] 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 <yuancan@huawei.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bb6642d commit b2073db

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/cpufreq/loongson2_cpufreq.c

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

155155
ret = cpufreq_register_driver(&loongson2_cpufreq_driver);
156156

157-
if (!ret && !nowait) {
157+
if (ret) {
158+
platform_driver_unregister(&platform_driver);
159+
} else if (!nowait) {
158160
saved_cpu_wait = cpu_wait;
159161
cpu_wait = loongson2_cpu_wait;
160162
}

0 commit comments

Comments
 (0)