• Lothar Waßmann's avatar
    [CPUFREQ] fix double unlock of cpu_policy_rwsem in drivers/cpufreq/cpufreq.c · dca02613
    Lothar Waßmann authored
    In drivers/cpufreq/cpufreq.c the function cpufreq_add_dev() takes the
    error exit 'err_out_unregister' from different places once with the
    'cpu_policy_rwsem' lock held, once with the lock released:
    |		if (ret)
    |			goto err_out_unregister;
    |	}
    |
    |	policy->governor = NULL; /* to assure that the starting sequence is
    |				  * run in cpufreq_set_policy */
    |
    |	/* set default policy */
    |	ret = __cpufreq_set_policy(policy, &new_policy);
    |	policy->user_policy.policy = policy->policy;
    |	policy->user_policy.governor = policy->governor;
    |
    |	unlock_policy_rwsem_write(cpu);
    |
    |	if (ret) {
    |		dprintk("setting policy failed\n");
    |		goto err_out_unregister;
    |	}
    
    This leads to the following error message in case of a failing
    __cpufreq_set_policy() call:
    =====================================
    [ BUG: bad unlock balance detected! ]
    -------------------------------------
    swapper/1 is trying to release lock (&per_cpu(cpu_policy_rwsem, cpu)) at:
    [<c01b4564...
    dca02613
cpufreq.c 47.7 KB