From: Eric Wong Date: Wed, 20 Mar 2013 04:07:48 +0000 (+1100) Subject: epoll: lock ep->mtx in ep_free to silence lockdep X-Git-Tag: next-20130320~2^2~268 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d1cabc79b47898ef564fa7156023bee39f8a7798;p=karo-tx-linux.git epoll: lock ep->mtx in ep_free to silence lockdep Technically we do not need to hold ep->mtx during ep_free since we are certain there are no other users of ep at that point. However, lockdep complains with a "suspicious rcu_dereference_check() usage!" message; so lock the mutex before ep_remove to silence the warning. Signed-off-by: Eric Wong Cc: Al Viro Cc: Arve Hjønnevåg Cc: Davide Libenzi Cc: Eric Dumazet Cc: NeilBrown , Cc: Rafael J. Wysocki Cc: Oleg Nesterov Signed-off-by: Andrew Morton --- diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 47ae9d96f0ac..67fc7f6559cc 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -776,11 +776,15 @@ static void ep_free(struct eventpoll *ep) * point we are sure no poll callbacks will be lingering around, and also by * holding "epmutex" we can be sure that no file cleanup code will hit * us during this operation. So we can avoid the lock on "ep->lock". + * We do not need to lock ep->mtx, either, we only do it to prevent + * a lockdep warning. */ + mutex_lock(&ep->mtx); while ((rbp = rb_first(&ep->rbr)) != NULL) { epi = rb_entry(rbp, struct epitem, rbn); ep_remove(ep, epi); } + mutex_unlock(&ep->mtx); mutex_unlock(&epmutex); mutex_destroy(&ep->mtx);