Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4496b39 authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

clockevents: prevent endless loop in periodic broadcast handler



The reprogramming of the periodic broadcast handler was broken,
when the first programming returned -ETIME. The clockevents code
stores the new expiry value in the clock events device next_event field
only when the programming time has not been elapsed yet. The loop in
question calculates the new expiry value from the next_event value
and therefor never increases.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 7c1e7689
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -175,6 +175,8 @@ static void tick_do_periodic_broadcast(void)
 */
 */
static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
{
{
	ktime_t next;

	tick_do_periodic_broadcast();
	tick_do_periodic_broadcast();


	/*
	/*
@@ -185,10 +187,13 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)


	/*
	/*
	 * Setup the next period for devices, which do not have
	 * Setup the next period for devices, which do not have
	 * periodic mode:
	 * periodic mode. We read dev->next_event first and add to it
	 * when the event alrady expired. clockevents_program_event()
	 * sets dev->next_event only when the event is really
	 * programmed to the device.
	 */
	 */
	for (;;) {
	for (next = dev->next_event; ;) {
		ktime_t next = ktime_add(dev->next_event, tick_period);
		next = ktime_add(next, tick_period);


		if (!clockevents_program_event(dev, next, ktime_get()))
		if (!clockevents_program_event(dev, next, ktime_get()))
			return;
			return;