Skip to content

Commit 2ed0d3d

Browse files
committed
udf: Avoid GFP_NOFS allocation in udf_symlink()
The GFP_NOFS allocation in udf_symlink() is called only under inode->i_rwsem and UDF_I(inode)->i_data_sem. The first is safe wrt reclaim, the second should be as well but allocating unde this lock is actually unnecessary. Move the allocation from under i_data_sem and change it to GFP_KERNEL. Signed-off-by: Jan Kara <[email protected]>
1 parent f676630 commit 2ed0d3d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

fs/udf/namei.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
566566
static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
567567
struct dentry *dentry, const char *symname)
568568
{
569-
struct inode *inode = udf_new_inode(dir, S_IFLNK | 0777);
569+
struct inode *inode;
570570
struct pathComponent *pc;
571571
const char *compstart;
572572
struct extent_position epos = {};
@@ -579,17 +579,20 @@ static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
579579
struct udf_inode_info *iinfo;
580580
struct super_block *sb = dir->i_sb;
581581

582-
if (IS_ERR(inode))
583-
return PTR_ERR(inode);
584-
585-
iinfo = UDF_I(inode);
586-
down_write(&iinfo->i_data_sem);
587-
name = kmalloc(UDF_NAME_LEN_CS0, GFP_NOFS);
582+
name = kmalloc(UDF_NAME_LEN_CS0, GFP_KERNEL);
588583
if (!name) {
589584
err = -ENOMEM;
590-
goto out_no_entry;
585+
goto out;
586+
}
587+
588+
inode = udf_new_inode(dir, S_IFLNK | 0777);
589+
if (IS_ERR(inode)) {
590+
err = PTR_ERR(inode);
591+
goto out;
591592
}
592593

594+
iinfo = UDF_I(inode);
595+
down_write(&iinfo->i_data_sem);
593596
inode->i_data.a_ops = &udf_symlink_aops;
594597
inode->i_op = &udf_symlink_inode_operations;
595598
inode_nohighmem(inode);

0 commit comments

Comments
 (0)