* grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0.

This commit is contained in:
Vladimir Serbinenko 2015-01-20 21:07:41 +01:00
parent 2e62352bc2
commit b666e01b9c
2 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,7 @@
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that

View file

@ -126,7 +126,7 @@ guessfsb (void)
{
const grub_uint64_t sane_value = 100000000;
grub_uint32_t manufacturer[3], max_cpuid, capabilities, msrlow;
grub_uint32_t a, b, d;
grub_uint32_t a, b, d, divisor;
if (! grub_cpu_is_cpuid_supported ())
return sane_value;
@ -166,8 +166,10 @@ guessfsb (void)
r = (2000ULL << 32) - v * grub_tsc_rate;
v += r / grub_tsc_rate;
return grub_divmod64 (v, ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1),
0);
divisor = ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1);
if (divisor == 0)
return sane_value;
return grub_divmod64 (v, divisor, 0);
}
struct property_descriptor