mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
x86: make clockevents more robust
detect zero event-device multiplicators - they then cause division-by-zero crashes if a clockevent has been initialized incorrectly. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
1a0c009ac5
commit
45fe4fe191
1 changed files with 13 additions and 0 deletions
|
@ -41,6 +41,11 @@ unsigned long clockevent_delta2ns(unsigned long latch,
|
||||||
{
|
{
|
||||||
u64 clc = ((u64) latch << evt->shift);
|
u64 clc = ((u64) latch << evt->shift);
|
||||||
|
|
||||||
|
if (unlikely(!evt->mult)) {
|
||||||
|
evt->mult = 1;
|
||||||
|
WARN_ON(1);
|
||||||
|
}
|
||||||
|
|
||||||
do_div(clc, evt->mult);
|
do_div(clc, evt->mult);
|
||||||
if (clc < 1000)
|
if (clc < 1000)
|
||||||
clc = 1000;
|
clc = 1000;
|
||||||
|
@ -151,6 +156,14 @@ static void clockevents_notify_released(void)
|
||||||
void clockevents_register_device(struct clock_event_device *dev)
|
void clockevents_register_device(struct clock_event_device *dev)
|
||||||
{
|
{
|
||||||
BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
|
BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
|
||||||
|
/*
|
||||||
|
* A nsec2cyc multiplicator of 0 is invalid and we'd crash
|
||||||
|
* on it, so fix it up and emit a warning:
|
||||||
|
*/
|
||||||
|
if (unlikely(!dev->mult)) {
|
||||||
|
dev->mult = 1;
|
||||||
|
WARN_ON(1);
|
||||||
|
}
|
||||||
|
|
||||||
spin_lock(&clockevents_lock);
|
spin_lock(&clockevents_lock);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue