Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=45fe4fe19120a22f7339f5bb110447170c25fca9
Commit:     45fe4fe19120a22f7339f5bb110447170c25fca9
Parent:     1a0c009ac53de4a7664a1239936f0bc258133156
Author:     Ingo Molnar <[EMAIL PROTECTED]>
AuthorDate: Wed Jan 30 13:30:03 2008 +0100
Committer:  Ingo Molnar <[EMAIL PROTECTED]>
CommitDate: Wed Jan 30 13:30:03 2008 +0100

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Thomas Gleixner <[EMAIL PROTECTED]>
---
 kernel/time/clockevents.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 5fb139f..3e59fce 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -41,6 +41,11 @@ unsigned long clockevent_delta2ns(unsigned long latch,
 {
        u64 clc = ((u64) latch << evt->shift);
 
+       if (unlikely(!evt->mult)) {
+               evt->mult = 1;
+               WARN_ON(1);
+       }
+
        do_div(clc, evt->mult);
        if (clc < 1000)
                clc = 1000;
@@ -151,6 +156,14 @@ static void clockevents_notify_released(void)
 void clockevents_register_device(struct clock_event_device *dev)
 {
        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);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to