Skip to content

Commit

Permalink
ubifs: Fix memory leak in RENAME_WHITEOUT error path in do_rename
Browse files Browse the repository at this point in the history
in RENAME_WHITEOUT error path, fscrypt_name should be freed.

Signed-off-by: Hyunchul Lee <cheol.lee@lge.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Hyunchul Lee authored and Richard Weinberger committed Jul 14, 2017
1 parent 4d35ca4 commit bb50c63
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions fs/ubifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,17 +1396,14 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,

dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
if (!dev) {
ubifs_release_budget(c, &req);
ubifs_release_budget(c, &ino_req);
return -ENOMEM;
err = -ENOMEM;
goto out_release;
}

err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
if (err) {
ubifs_release_budget(c, &req);
ubifs_release_budget(c, &ino_req);
kfree(dev);
return err;
goto out_release;
}

whiteout->i_state |= I_LINKABLE;
Expand Down Expand Up @@ -1494,12 +1491,10 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,

err = ubifs_budget_space(c, &wht_req);
if (err) {
ubifs_release_budget(c, &req);
ubifs_release_budget(c, &ino_req);
kfree(whiteout_ui->data);
whiteout_ui->data_len = 0;
iput(whiteout);
return err;
goto out_release;
}

inc_nlink(whiteout);
Expand Down Expand Up @@ -1554,6 +1549,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
iput(whiteout);
}
unlock_4_inodes(old_dir, new_dir, new_inode, whiteout);
out_release:
ubifs_release_budget(c, &ino_req);
ubifs_release_budget(c, &req);
fscrypt_free_filename(&old_nm);
Expand Down

0 comments on commit bb50c63

Please sign in to comment.