Skip to content

Commit 9f5ecac

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubifs: Move ui->data initialization after initializing security
Host inode and its' xattr will be written on disk after initializing security when creating symlink or dev, then the host inode and its dentry will be written again in ubifs_jnl_update. There is no need to write inode data in the security initialization pass, just move the ui->data initialization after initializing security. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 7efc34b commit 9f5ecac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fs/ubifs/dir.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,16 +1102,18 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
11021102
goto out_fname;
11031103
}
11041104

1105+
err = ubifs_init_security(dir, inode, &dentry->d_name);
1106+
if (err) {
1107+
kfree(dev);
1108+
goto out_inode;
1109+
}
1110+
11051111
init_special_inode(inode, inode->i_mode, rdev);
11061112
inode->i_size = ubifs_inode(inode)->ui_size = devlen;
11071113
ui = ubifs_inode(inode);
11081114
ui->data = dev;
11091115
ui->data_len = devlen;
11101116

1111-
err = ubifs_init_security(dir, inode, &dentry->d_name);
1112-
if (err)
1113-
goto out_inode;
1114-
11151117
mutex_lock(&dir_ui->ui_mutex);
11161118
dir->i_size += sz_change;
11171119
dir_ui->ui_size = dir->i_size;
@@ -1184,6 +1186,10 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
11841186
goto out_fname;
11851187
}
11861188

1189+
err = ubifs_init_security(dir, inode, &dentry->d_name);
1190+
if (err)
1191+
goto out_inode;
1192+
11871193
ui = ubifs_inode(inode);
11881194
ui->data = kmalloc(disk_link.len, GFP_NOFS);
11891195
if (!ui->data) {
@@ -1209,10 +1215,6 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
12091215
ui->data_len = disk_link.len - 1;
12101216
inode->i_size = ubifs_inode(inode)->ui_size = disk_link.len - 1;
12111217

1212-
err = ubifs_init_security(dir, inode, &dentry->d_name);
1213-
if (err)
1214-
goto out_inode;
1215-
12161218
mutex_lock(&dir_ui->ui_mutex);
12171219
dir->i_size += sz_change;
12181220
dir_ui->ui_size = dir->i_size;

0 commit comments

Comments
 (0)