]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/file_table.c
vfs/fsnotify: fsnotify_close can delay the final work in fput
[net-next-2.6.git] / fs / file_table.c
index 5c7d10ead4ad774981f294428bd1ef7fa9e4cccf..b8a0bb63cbd7c877cd69ac3b445c385ed2e60ba3 100644 (file)
@@ -230,6 +230,15 @@ static void __fput(struct file *file)
        might_sleep();
 
        fsnotify_close(file);
+
+       /*
+        * fsnotify_create_event may have taken one or more references on this
+        * file.  If it did so it left one reference for us to drop to make sure
+        * its calls to fput could not prematurely destroy the file.
+        */
+       if (atomic_long_read(&file->f_count))
+               return fput(file);
+
        /*
         * The function eventpoll_release() should be the first called
         * in the file cleanup chain.