Before faking up a state table, make sure that neither frequency nor
voltage difference is 0. This avoids a divide by zero.
This commit is contained in:
parent
03ececeaba
commit
25f1319b9a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: est.c,v 1.3 2007/08/06 03:38:49 simonb Exp $ */
|
||||
/* $NetBSD: est.c,v 1.4 2007/10/24 06:21:32 joerg Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2003 Michael Eriksson.
|
||||
* All rights reserved.
|
||||
|
@ -86,7 +86,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.3 2007/08/06 03:38:49 simonb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.4 2007/10/24 06:21:32 joerg Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1199,6 +1199,11 @@ est_init_main(int vendor)
|
|||
maxvolt = MSR2VOLTINC(idhi);
|
||||
freqinc = maxfreq - minfreq;
|
||||
voltinc = maxvolt - minvolt;
|
||||
|
||||
/* Avoid diving by zero. */
|
||||
if (freqinc == 0 || voltinc == 0)
|
||||
return;
|
||||
|
||||
if (freqinc < voltinc) {
|
||||
tablesize = maxfreq - minfreq + 1;
|
||||
voltinc = voltinc * 100 / freqinc - 1;
|
||||
|
|
Loading…
Reference in New Issue