Skip to content

Commit ee34c52

Browse files
committed
tracefs: Use d_inode() helper function to get the dentry inode
Instead of referencing the inode from a dentry via dentry->d_inode, use the helper function d_inode(dentry) instead. This is the considered the correct way to access it. Reported-by: Christian Brauner <[email protected]> Reported: https://lore.kernel.org/all/20211208104454.nhxyvmmn6d2qhpwl@wittgenstein/ Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent c8a7ff1 commit ee34c52

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

fs/tracefs/inode.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ static int tracefs_syscall_rmdir(struct inode *inode, struct dentry *dentry)
109109
* also the directory that is being deleted.
110110
*/
111111
inode_unlock(inode);
112-
inode_unlock(dentry->d_inode);
112+
inode_unlock(d_inode(dentry));
113113

114114
ret = tracefs_ops.rmdir(name);
115115

116116
inode_lock_nested(inode, I_MUTEX_PARENT);
117-
inode_lock(dentry->d_inode);
117+
inode_lock(d_inode(dentry));
118118

119119
kfree(name);
120120

@@ -212,7 +212,7 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
212212
static int tracefs_apply_options(struct super_block *sb)
213213
{
214214
struct tracefs_fs_info *fsi = sb->s_fs_info;
215-
struct inode *inode = sb->s_root->d_inode;
215+
struct inode *inode = d_inode(sb->s_root);
216216
struct tracefs_mount_opts *opts = &fsi->mount_opts;
217217

218218
inode->i_mode &= ~S_IALLUGO;
@@ -331,18 +331,18 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
331331
if (!parent)
332332
parent = tracefs_mount->mnt_root;
333333

334-
inode_lock(parent->d_inode);
335-
if (unlikely(IS_DEADDIR(parent->d_inode)))
334+
inode_lock(d_inode(parent));
335+
if (unlikely(IS_DEADDIR(d_inode(parent))))
336336
dentry = ERR_PTR(-ENOENT);
337337
else
338338
dentry = lookup_one_len(name, parent, strlen(name));
339-
if (!IS_ERR(dentry) && dentry->d_inode) {
339+
if (!IS_ERR(dentry) && d_inode(dentry)) {
340340
dput(dentry);
341341
dentry = ERR_PTR(-EEXIST);
342342
}
343343

344344
if (IS_ERR(dentry)) {
345-
inode_unlock(parent->d_inode);
345+
inode_unlock(d_inode(parent));
346346
simple_release_fs(&tracefs_mount, &tracefs_mount_count);
347347
}
348348

@@ -351,15 +351,15 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
351351

352352
static struct dentry *failed_creating(struct dentry *dentry)
353353
{
354-
inode_unlock(dentry->d_parent->d_inode);
354+
inode_unlock(d_inode(dentry->d_parent));
355355
dput(dentry);
356356
simple_release_fs(&tracefs_mount, &tracefs_mount_count);
357357
return NULL;
358358
}
359359

360360
static struct dentry *end_creating(struct dentry *dentry)
361361
{
362-
inode_unlock(dentry->d_parent->d_inode);
362+
inode_unlock(d_inode(dentry->d_parent));
363363
return dentry;
364364
}
365365

@@ -415,7 +415,7 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
415415
inode->i_fop = fops ? fops : &tracefs_file_operations;
416416
inode->i_private = data;
417417
d_instantiate(dentry, inode);
418-
fsnotify_create(dentry->d_parent->d_inode, dentry);
418+
fsnotify_create(d_inode(dentry->d_parent), dentry);
419419
return end_creating(dentry);
420420
}
421421

@@ -440,8 +440,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
440440
/* directory inodes start off with i_nlink == 2 (for "." entry) */
441441
inc_nlink(inode);
442442
d_instantiate(dentry, inode);
443-
inc_nlink(dentry->d_parent->d_inode);
444-
fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
443+
inc_nlink(d_inode(dentry->d_parent));
444+
fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
445445
return end_creating(dentry);
446446
}
447447

0 commit comments

Comments
 (0)