cpufreq: fix missing unlocks in cpufreq_add_dev error paths.

Ingo hit some BUG_ONs that were probably caused by these missing unlocks
causing an unbalance. He couldn't reproduce the bug reliably, so it's
unknown that it's definitly fixing the problem he hit, but it's a fairly
good chance, and this fixes an obvious bug.

[ Dave: "Ingo followed up that he hit some lockdep related output with
this applied, so it may not be right. I'll look at it after
xmas if no-one has it figured out before then."
Akpm: "It looks pretty correct to me though." ]

Signed-off-by: Dave Jones <davej@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dave Jones and committed by
Linus Torvalds
bd6cba53 9548b209

+9 -3
+9 -3
drivers/cpufreq/cpufreq.c
··· 841 drv_attr = cpufreq_driver->attr; 842 while ((drv_attr) && (*drv_attr)) { 843 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); 844 - if (ret) 845 goto err_out_driver_exit; 846 drv_attr++; 847 } 848 if (cpufreq_driver->get){ 849 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 850 - if (ret) 851 goto err_out_driver_exit; 852 } 853 if (cpufreq_driver->target){ 854 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 855 - if (ret) 856 goto err_out_driver_exit; 857 } 858 859 spin_lock_irqsave(&cpufreq_driver_lock, flags);
··· 841 drv_attr = cpufreq_driver->attr; 842 while ((drv_attr) && (*drv_attr)) { 843 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); 844 + if (ret) { 845 + unlock_policy_rwsem_write(cpu); 846 goto err_out_driver_exit; 847 + } 848 drv_attr++; 849 } 850 if (cpufreq_driver->get){ 851 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 852 + if (ret) { 853 + unlock_policy_rwsem_write(cpu); 854 goto err_out_driver_exit; 855 + } 856 } 857 if (cpufreq_driver->target){ 858 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 859 + if (ret) { 860 + unlock_policy_rwsem_write(cpu); 861 goto err_out_driver_exit; 862 + } 863 } 864 865 spin_lock_irqsave(&cpufreq_driver_lock, flags);