diff options
author | njl <njl@FreeBSD.org> | 2005-03-31 18:56:54 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2005-03-31 18:56:54 +0000 |
commit | 749e1a55dd5e3539c5d33c568729586e27fd92a7 (patch) | |
tree | 69c2e591eacbae8f0580c73d3a17046c7155bade | |
parent | e228fee2c2c57b384e368d88f25dbc4699a9c423 (diff) | |
download | FreeBSD-src-749e1a55dd5e3539c5d33c568729586e27fd92a7.zip FreeBSD-src-749e1a55dd5e3539c5d33c568729586e27fd92a7.tar.gz |
Add a check for cpufreq_unregister() being called with no cpufreq device
active. Note that the logic indicates this should not be possible so
generate a warning if this ever happens.
Found by: Coverity Prevent (via sam)
-rw-r--r-- | sys/kern/kern_cpu.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 0688b49..4ee43cf 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -900,6 +900,11 @@ cpufreq_unregister(device_t dev) if (error) return (error); cf_dev = device_find_child(device_get_parent(dev), "cpufreq", -1); + if (cf_dev == NULL) { + device_printf(dev, + "warning: cpufreq_unregister called with no cpufreq device active\n"); + return (0); + } cfcount = 0; for (i = 0; i < devcount; i++) { if (!device_is_attached(devs[i])) |