fsnotify: Move locking into fsnotify_find_mark()
[sfrench/cifs-2.6.git] / fs / notify / mark.c
index 06faf166c7aecbccb8589c52b72f1d08d963409a..0830e0af997a5df9ce67469a7112b8fc483ae3d4 100644 (file)
@@ -485,16 +485,24 @@ struct fsnotify_mark *fsnotify_find_mark(struct fsnotify_mark_connector *conn,
                                         struct fsnotify_group *group)
 {
        struct fsnotify_mark *mark;
+       spinlock_t *lock;
 
        if (!conn)
                return NULL;
 
+       if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
+               lock = &conn->inode->i_lock;
+       else
+               lock = &conn->mnt->mnt_root->d_lock;
+       spin_lock(lock);
        hlist_for_each_entry(mark, &conn->list, obj_list) {
                if (mark->group == group) {
                        fsnotify_get_mark(mark);
+                       spin_unlock(lock);
                        return mark;
                }
        }
+       spin_unlock(lock);
        return NULL;
 }