From 4fb93663e6a44fb3530d1bfd400bf14fbd144028 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 5 May 2008 19:13:52 +0000 Subject: [PATCH] Fix a few edge cases with error handling in cpufreq(4)'s CPUFREQ_GET() method: - If the last of the child cpufreq drivers returns an error while trying to fetch its list of supported frequencies but an earlier driver found the requested frequency, don't return an error to the caller. - If all of the child cpufreq drivers fail and the attempt to match the frequency based on 'cpu_est_clockrate()' fails, return ENXIO rather than returning success and returning a frequency of CPUFREQ_VAL_UNKNOWN. MFC after: 3 days PR: kern/121433 Reported by: Eugene Grosbein eugen ! kuzbass dot ru --- sys/kern/kern_cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index f8f8c3670fac..50fff533333e 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -452,8 +452,7 @@ cf_get_method(device_t dev, struct cf_level *level) for (n = 0; n < numdevs && curr_set->freq == CPUFREQ_VAL_UNKNOWN; n++) { if (!device_is_attached(devs[n])) continue; - error = CPUFREQ_DRV_GET(devs[n], &set); - if (error) + if (CPUFREQ_DRV_GET(devs[n], &set) != 0) continue; for (i = 0; i < count; i++) { if (CPUFREQ_CMP(set.freq, levels[i].total_set.freq)) { @@ -483,9 +482,10 @@ cf_get_method(device_t dev, struct cf_level *level) if (CPUFREQ_CMP(rate, levels[i].total_set.freq)) { sc->curr_level = levels[i]; CF_DEBUG("get estimated freq %d\n", curr_set->freq); - break; + goto out; } } + error = ENXIO; out: if (error == 0)