mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	posix-cpu-timers: Correctly update timer status in posix_cpu_timer_del()
If posix_cpu_timer_del() exits early due to task not found or sighand invalid, it fails to clear the state of the timer. That's harmless but inconsistent. These early exits are accounted as successful delete. Move the update of the timer state into the success return path, so all "successful" deletions are handled. Reported-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lore.kernel.org/all/20241105064212.974053438@linutronix.de
This commit is contained in:
		
							parent
							
								
									c163e40af9
								
							
						
					
					
						commit
						15cbfb92ef
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -493,20 +493,20 @@ static int posix_cpu_timer_del(struct k_itimer *timer)
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		WARN_ON_ONCE(ctmr->head || timerqueue_node_queued(&ctmr->node));
 | 
							WARN_ON_ONCE(ctmr->head || timerqueue_node_queued(&ctmr->node));
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (timer->it.cpu.firing) {
 | 
							if (timer->it.cpu.firing)
 | 
				
			||||||
			ret = TIMER_RETRY;
 | 
								ret = TIMER_RETRY;
 | 
				
			||||||
		} else {
 | 
							else
 | 
				
			||||||
			disarm_timer(timer, p);
 | 
								disarm_timer(timer, p);
 | 
				
			||||||
			timer->it_status = POSIX_TIMER_DISARMED;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		unlock_task_sighand(p, &flags);
 | 
							unlock_task_sighand(p, &flags);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	rcu_read_unlock();
 | 
						rcu_read_unlock();
 | 
				
			||||||
	if (!ret)
 | 
					 | 
				
			||||||
		put_pid(ctmr->pid);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!ret) {
 | 
				
			||||||
 | 
							put_pid(ctmr->pid);
 | 
				
			||||||
 | 
							timer->it_status = POSIX_TIMER_DISARMED;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue