summaryrefslogtreecommitdiff
path: root/fs/debugfs/internal.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2023-11-24 17:25:24 +0100
committerJohannes Berg <johannes.berg@intel.com>2023-11-27 11:24:45 +0100
commit0ed04a1847a10297595ac24dc7d46b35fb35f90a (patch)
tree4aecc9d5e6d1aafa25a04cdeac454adb080459b5 /fs/debugfs/internal.h
parent00f7d153f3358a7c7e35aef66fcd9ceb95d90430 (diff)
debugfs: fix automount d_fsdata usage
debugfs_create_automount() stores a function pointer in d_fsdata, but since commit 7c8d469877b1 ("debugfs: add support for more elaborate ->d_fsdata") debugfs_release_dentry() will free it, now conditionally on DEBUGFS_FSDATA_IS_REAL_FOPS_BIT, but that's not set for the function pointer in automount. As a result, removing an automount dentry would attempt to free the function pointer. Luckily, the only user of this (tracing) never removes it. Nevertheless, it's safer if we just handle the fsdata in one way, namely either DEBUGFS_FSDATA_IS_REAL_FOPS_BIT or allocated. Thus, change the automount to allocate it, and use the real_fops in the data to indicate whether or not automount is filled, rather than adding a type tag. At least for now this isn't actually needed, but the next changes will require it. Also check in debugfs_file_get() that it gets only called on regular files, just to make things clearer. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'fs/debugfs/internal.h')
-rw-r--r--fs/debugfs/internal.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/debugfs/internal.h b/fs/debugfs/internal.h
index 92af8ae31313..f7c489b5a368 100644
--- a/fs/debugfs/internal.h
+++ b/fs/debugfs/internal.h
@@ -17,8 +17,14 @@ extern const struct file_operations debugfs_full_proxy_file_operations;
struct debugfs_fsdata {
const struct file_operations *real_fops;
- refcount_t active_users;
- struct completion active_users_drained;
+ union {
+ /* automount_fn is used when real_fops is NULL */
+ debugfs_automount_t automount;
+ struct {
+ refcount_t active_users;
+ struct completion active_users_drained;
+ };
+ };
};
/*