]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
epoll: lock ep->mtx in ep_free to silence lockdep
authorEric Wong <normalperson@yhbt.net>
Wed, 20 Mar 2013 04:07:48 +0000 (15:07 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 22 Mar 2013 04:33:26 +0000 (15:33 +1100)
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 <normalperson@yhbt.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: NeilBrown <neilb@suse.de>,
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/eventpoll.c

index 47ae9d96f0ac4d1e7b44fd4d79571b298cd3e510..67fc7f6559cc5bb61e52b0e46352172e95a0eb90 100644 (file)
@@ -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);