summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2025-01-29 19:19:37 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-30 08:22:31 +0100
commit57b314752ec0ad42685bc78b376326f1f4c04669 (patch)
treef490d8b8bb0769ad1677bb36f336af539f275291
parent72deda0abee6e705ae71a93f69f55e33be5bca5c (diff)
debugfs: Fix the missing initializations in __debugfs_file_get()
both method table pointers in debugfs_fsdata need to be initialized, obviously, and calculating the bitmap of present methods would also go better if we start with initialized state. Fixes: 41a0ecc0997c ("debugfs: get rid of dynamically allocation proxy_ops") Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/r/20250129191937.GR1977892@ZenIV Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/debugfs/file.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index e33cc77699cd..69e9ddcb113d 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -94,6 +94,7 @@ static int __debugfs_file_get(struct dentry *dentry, enum dbgfs_get_mode mode)
fsd = d_fsd;
} else {
struct inode *inode = dentry->d_inode;
+ unsigned int methods = 0;
if (WARN_ON(mode == DBGFS_GET_ALREADY))
return -EINVAL;
@@ -106,25 +107,28 @@ static int __debugfs_file_get(struct dentry *dentry, enum dbgfs_get_mode mode)
const struct debugfs_short_fops *ops;
ops = fsd->short_fops = DEBUGFS_I(inode)->short_fops;
if (ops->llseek)
- fsd->methods |= HAS_LSEEK;
+ methods |= HAS_LSEEK;
if (ops->read)
- fsd->methods |= HAS_READ;
+ methods |= HAS_READ;
if (ops->write)
- fsd->methods |= HAS_WRITE;
+ methods |= HAS_WRITE;
+ fsd->real_fops = NULL;
} else {
const struct file_operations *ops;
ops = fsd->real_fops = DEBUGFS_I(inode)->real_fops;
if (ops->llseek)
- fsd->methods |= HAS_LSEEK;
+ methods |= HAS_LSEEK;
if (ops->read)
- fsd->methods |= HAS_READ;
+ methods |= HAS_READ;
if (ops->write)
- fsd->methods |= HAS_WRITE;
+ methods |= HAS_WRITE;
if (ops->unlocked_ioctl)
- fsd->methods |= HAS_IOCTL;
+ methods |= HAS_IOCTL;
if (ops->poll)
- fsd->methods |= HAS_POLL;
+ methods |= HAS_POLL;
+ fsd->short_fops = NULL;
}
+ fsd->methods = methods;
refcount_set(&fsd->active_users, 1);
init_completion(&fsd->active_users_drained);
INIT_LIST_HEAD(&fsd->cancellations);