debugfs: annotate debugfs handlers vs. removal with lockdep
[linux-2.6-microblaze.git] / fs / debugfs / inode.c
index dcde419..80f4f00 100644 (file)
@@ -241,6 +241,14 @@ static void debugfs_release_dentry(struct dentry *dentry)
        if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
                return;
 
+       /* check it wasn't a dir (no fsdata) or automount (no real_fops) */
+       if (fsd && fsd->real_fops) {
+#ifdef CONFIG_LOCKDEP
+               lockdep_unregister_key(&fsd->key);
+               kfree(fsd->lock_name);
+#endif
+       }
+
        kfree(fsd);
 }
 
@@ -744,6 +752,10 @@ static void __debugfs_file_removed(struct dentry *dentry)
        fsd = READ_ONCE(dentry->d_fsdata);
        if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
                return;
+
+       lock_map_acquire(&fsd->lockdep_map);
+       lock_map_release(&fsd->lockdep_map);
+
        if (!refcount_dec_and_test(&fsd->active_users))
                wait_for_completion(&fsd->active_users_drained);
 }