Skip to content

Commit

Permalink
posix-timers: Annotate lock_timer()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
namhyung authored and KAGA-KOKO committed Oct 21, 2010
1 parent dd6414b commit 20f33a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kernel/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ static int common_timer_del(struct k_itimer *timer);

static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);

static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags);

#define lock_timer(tid, flags) \
({ struct k_itimer *__timr; \
__cond_lock(&__timr->it_lock, __timr = __lock_timer(tid, flags)); \
__timr; \
})

static inline void unlock_timer(struct k_itimer *timr, unsigned long flags)
{
Expand Down Expand Up @@ -619,7 +625,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
* the find to the timer lock. To avoid a dead lock, the timer id MUST
* be release with out holding the timer lock.
*/
static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags)
static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags)
{
struct k_itimer *timr;
/*
Expand Down

0 comments on commit 20f33a0

Please sign in to comment.