[android-common:android14-kiwi-6.1 180/180] kernel/time/posix-timers.c:1079 itimer_delete() warn: inconsistent returns '&timer->it_lock'.

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
TO: [email protected]

tree:   https://android.googlesource.com/kernel/common android14-kiwi-6.1
head:   1517b793772a02ed13258dd27cd6ac22fe27c5a6
commit: e7aff15ba29ba4b3052786b1636fa5c4aa39e179 [180/180] posix-timers: Prevent RT livelock in itimer_delete()
:::::: branch date: 18 hours ago
:::::: commit date: 3 years ago
config: x86_64-randconfig-161-20260708 (https://download.01.org/0day-ci/archive/20260712/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9185-gbcc58b9c

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
kernel/time/posix-timers.c:1079 itimer_delete() warn: inconsistent returns '&timer->it_lock'.

vim +1079 kernel/time/posix-timers.c

becf8b5d00f4b4 kernel/posix-timers.c      Thomas Gleixner  2006-01-09  1038  
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1039  /*
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1040   * Delete a timer if it is armed, remove it from the hash and schedule it
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1041   * for RCU freeing.
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1042   */
858119e1593843 kernel/posix-timers.c      Arjan van de Ven 2006-01-14  1043  static void itimer_delete(struct k_itimer *timer)
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1044  {
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1045  	unsigned long flags;
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1046  
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1047  	/*
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1048  	 * irqsave is required to make timer_wait_running() work.
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1049  	 */
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1050  	spin_lock_irqsave(&timer->it_lock, flags);
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1051  
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1052  retry_delete:
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1053  	/*
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1054  	 * Even if the timer is not longer accessible from other tasks
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1055  	 * it still might be armed and queued in the underlying timer
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1056  	 * mechanism. Worse, that timer mechanism might run the expiry
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1057  	 * function concurrently.
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1058  	 */
becf8b5d00f4b4 kernel/posix-timers.c      Thomas Gleixner  2006-01-09  1059  	if (timer_delete_hook(timer) == TIMER_RETRY) {
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1060  		/*
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1061  		 * Timer is expired concurrently, prevent livelocks
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1062  		 * and pointless spinning on RT.
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1063  		 *
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1064  		 * timer_wait_running() drops timer::it_lock, which opens
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1065  		 * the possibility for another task to delete the timer.
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1066  		 *
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1067  		 * That's not possible here because this is invoked from
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1068  		 * do_exit() only for the last thread of the thread group.
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1069  		 * So no other task can access and delete that timer.
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1070  		 */
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1071  		if (WARN_ON_ONCE(timer_wait_running(timer, &flags) != timer))
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1072  			return;
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1073  
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1074  		goto retry_delete;
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1075  	}
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1076  	list_del(&timer->list);
4b7a1304267bff kernel/posix-timers.c      Oleg Nesterov    2008-07-25  1077  
e7aff15ba29ba4 kernel/time/posix-timers.c Thomas Gleixner  2023-06-01  1078  	spin_unlock_irqrestore(&timer->it_lock, flags);
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16 @1079  	release_posix_timer(timer, IT_ID_SET);
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1080  }
^1da177e4c3f41 kernel/posix-timers.c      Linus Torvalds   2005-04-16  1081  

:::::: The code at line 1079 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.