Commit 53cc2820acbdbcc768675bfaff321f3a8680a317

Authored by Thomas Gleixner
Committed by John Stultz
1 parent ef68c8f87e

rtc: Handle errors correctly in rtc_irq_set_state()

In rtc_irq_set_state, the code checks the correctness of the parameters,
but then goes on to unconditionally arms/disarms the hrtimer. Thus a
random task might arm/disarm rtc timer and surprise the real owner by
either generating events or by stopping them.

Cc: stable@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

drivers/rtc/interface.c
... ... @@ -656,6 +656,8 @@
656 656 err = -EBUSY;
657 657 if (rtc->irq_task != task)
658 658 err = -EACCES;
  659 + if (err)
  660 + goto out;
659 661  
660 662 if (enabled) {
661 663 ktime_t period = ktime_set(0, NSEC_PER_SEC/rtc->irq_freq);
... ... @@ -664,6 +666,7 @@
664 666 hrtimer_cancel(&rtc->pie_timer);
665 667 }
666 668 rtc->pie_enabled = enabled;
  669 +out:
667 670 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
668 671  
669 672 return err;