epoll: lock ep->mtx in ep_free to silence lockdep
authorEric Wong <[email protected]>
Tue, 30 Apr 2013 22:27:40 +0000 (15:27 -0700)
committerLinus Torvalds <[email protected]>
Wed, 1 May 2013 00:04:04 +0000 (17:04 -0700)
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 <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Arve Hjønnevåg <[email protected]>
Cc: Davide Libenzi <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: NeilBrown <[email protected]>,
Cc: Rafael J. Wysocki <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/eventpoll.c

index a3acf936c72af92e7316be81a3f5b4900a1fd518..5744a7f01875cba71e11d20a20a0008e967de319 100644 (file)
@@ -745,11 +745,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);