fsnotify: Protect bail out path of fsnotify_add_mark_locked() properly
[sfrench/cifs-2.6.git] / fs / notify / mark.c
index 9991f88267342f9e699655cc29129225334e8dd6..47a827975b5878b3052d83cf9467cf00ebaecf32 100644 (file)
@@ -599,9 +599,11 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark, struct inode *inode,
 
        return ret;
 err:
+       spin_lock(&mark->lock);
        mark->flags &= ~(FSNOTIFY_MARK_FLAG_ALIVE |
                         FSNOTIFY_MARK_FLAG_ATTACHED);
        list_del_init(&mark->g_list);
+       spin_unlock(&mark->lock);
        atomic_dec(&group->num_marks);
 
        fsnotify_put_mark(mark);