Skip to content

Commit 57b3147

Browse files
Al Virogregkh
authored andcommitted
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: 41a0ecc ("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>
1 parent 72deda0 commit 57b3147

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

fs/debugfs/file.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static int __debugfs_file_get(struct dentry *dentry, enum dbgfs_get_mode mode)
9494
fsd = d_fsd;
9595
} else {
9696
struct inode *inode = dentry->d_inode;
97+
unsigned int methods = 0;
9798

9899
if (WARN_ON(mode == DBGFS_GET_ALREADY))
99100
return -EINVAL;
@@ -106,25 +107,28 @@ static int __debugfs_file_get(struct dentry *dentry, enum dbgfs_get_mode mode)
106107
const struct debugfs_short_fops *ops;
107108
ops = fsd->short_fops = DEBUGFS_I(inode)->short_fops;
108109
if (ops->llseek)
109-
fsd->methods |= HAS_LSEEK;
110+
methods |= HAS_LSEEK;
110111
if (ops->read)
111-
fsd->methods |= HAS_READ;
112+
methods |= HAS_READ;
112113
if (ops->write)
113-
fsd->methods |= HAS_WRITE;
114+
methods |= HAS_WRITE;
115+
fsd->real_fops = NULL;
114116
} else {
115117
const struct file_operations *ops;
116118
ops = fsd->real_fops = DEBUGFS_I(inode)->real_fops;
117119
if (ops->llseek)
118-
fsd->methods |= HAS_LSEEK;
120+
methods |= HAS_LSEEK;
119121
if (ops->read)
120-
fsd->methods |= HAS_READ;
122+
methods |= HAS_READ;
121123
if (ops->write)
122-
fsd->methods |= HAS_WRITE;
124+
methods |= HAS_WRITE;
123125
if (ops->unlocked_ioctl)
124-
fsd->methods |= HAS_IOCTL;
126+
methods |= HAS_IOCTL;
125127
if (ops->poll)
126-
fsd->methods |= HAS_POLL;
128+
methods |= HAS_POLL;
129+
fsd->short_fops = NULL;
127130
}
131+
fsd->methods = methods;
128132
refcount_set(&fsd->active_users, 1);
129133
init_completion(&fsd->active_users_drained);
130134
INIT_LIST_HEAD(&fsd->cancellations);

0 commit comments

Comments
 (0)