Skip to content

Commit

Permalink
signals: annotate lock_task_sighand()
Browse files Browse the repository at this point in the history
lock_task_sighand() grabs sighand->siglock in case of returning non-NULL
but unlock_task_sighand() releases it unconditionally.  This leads sparse
to complain about the lock context imbalance.  Rename and wrap
lock_task_sighand() using __cond_lock() macro to make sparse happy.

Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Namhyung Kim authored and Linus Torvalds committed Oct 28, 2010
1 parent 5ef4507 commit b8ed374
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -2236,9 +2236,16 @@ static inline void task_unlock(struct task_struct *p)
spin_unlock(&p->alloc_lock);
}

extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
unsigned long *flags);

#define lock_task_sighand(tsk, flags) \
({ struct sighand_struct *__ss; \
__cond_lock(&(tsk)->sighand->siglock, \
(__ss = __lock_task_sighand(tsk, flags))); \
__ss; \
}) \

static inline void unlock_task_sighand(struct task_struct *tsk,
unsigned long *flags)
{
Expand Down
3 changes: 2 additions & 1 deletion kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,8 @@ int zap_other_threads(struct task_struct *p)
return count;
}

struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags)
struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
unsigned long *flags)
{
struct sighand_struct *sighand;

Expand Down

0 comments on commit b8ed374

Please sign in to comment.