Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

posix-timers: Annotate lock_timer()

lock_timer() conditionally grabs it_lock in case of returning non-NULL
but unlock_timer() releases it unconditionally. This leads sparse to
complain about the lock context imbalance. Rename and wrap lock_timer
using __cond_lock() macro to make sparse happy.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Namhyung Kim and committed by
Thomas Gleixner
20f33a03 dd6414b5

+8 -2
+8 -2
kernel/posix-timers.c
··· 145 145 146 146 static enum hrtimer_restart posix_timer_fn(struct hrtimer *data); 147 147 148 - static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); 148 + static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags); 149 + 150 + #define lock_timer(tid, flags) \ 151 + ({ struct k_itimer *__timr; \ 152 + __cond_lock(&__timr->it_lock, __timr = __lock_timer(tid, flags)); \ 153 + __timr; \ 154 + }) 149 155 150 156 static inline void unlock_timer(struct k_itimer *timr, unsigned long flags) 151 157 { ··· 625 619 * the find to the timer lock. To avoid a dead lock, the timer id MUST 626 620 * be release with out holding the timer lock. 627 621 */ 628 - static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags) 622 + static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags) 629 623 { 630 624 struct k_itimer *timr; 631 625 /*