diff options
author | Hyunchul Lee <cheol.lee@lge.com> | 2017-05-16 19:58:02 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2017-07-14 16:49:05 -0400 |
commit | bb50c63244687706e11c9b636a5ad3090cd783ac (patch) | |
tree | 68e8816798e804db7259ac49f95ca6b916529636 | |
parent | 4d35ca4f774c29ec9ed676fd5112bfc83ef9853e (diff) |
ubifs: Fix memory leak in RENAME_WHITEOUT error path in do_rename
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>
-rw-r--r-- | fs/ubifs/dir.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 4e4bf8f6320f..996e4215fd28 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
@@ -1396,17 +1396,14 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1396 | 1396 | ||
1397 | dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS); | 1397 | dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS); |
1398 | if (!dev) { | 1398 | if (!dev) { |
1399 | ubifs_release_budget(c, &req); | 1399 | err = -ENOMEM; |
1400 | ubifs_release_budget(c, &ino_req); | 1400 | goto out_release; |
1401 | return -ENOMEM; | ||
1402 | } | 1401 | } |
1403 | 1402 | ||
1404 | err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout); | 1403 | err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout); |
1405 | if (err) { | 1404 | if (err) { |
1406 | ubifs_release_budget(c, &req); | ||
1407 | ubifs_release_budget(c, &ino_req); | ||
1408 | kfree(dev); | 1405 | kfree(dev); |
1409 | return err; | 1406 | goto out_release; |
1410 | } | 1407 | } |
1411 | 1408 | ||
1412 | whiteout->i_state |= I_LINKABLE; | 1409 | whiteout->i_state |= I_LINKABLE; |
@@ -1494,12 +1491,10 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1494 | 1491 | ||
1495 | err = ubifs_budget_space(c, &wht_req); | 1492 | err = ubifs_budget_space(c, &wht_req); |
1496 | if (err) { | 1493 | if (err) { |
1497 | ubifs_release_budget(c, &req); | ||
1498 | ubifs_release_budget(c, &ino_req); | ||
1499 | kfree(whiteout_ui->data); | 1494 | kfree(whiteout_ui->data); |
1500 | whiteout_ui->data_len = 0; | 1495 | whiteout_ui->data_len = 0; |
1501 | iput(whiteout); | 1496 | iput(whiteout); |
1502 | return err; | 1497 | goto out_release; |
1503 | } | 1498 | } |
1504 | 1499 | ||
1505 | inc_nlink(whiteout); | 1500 | inc_nlink(whiteout); |
@@ -1554,6 +1549,7 @@ out_cancel: | |||
1554 | iput(whiteout); | 1549 | iput(whiteout); |
1555 | } | 1550 | } |
1556 | unlock_4_inodes(old_dir, new_dir, new_inode, whiteout); | 1551 | unlock_4_inodes(old_dir, new_dir, new_inode, whiteout); |
1552 | out_release: | ||
1557 | ubifs_release_budget(c, &ino_req); | 1553 | ubifs_release_budget(c, &ino_req); |
1558 | ubifs_release_budget(c, &req); | 1554 | ubifs_release_budget(c, &req); |
1559 | fscrypt_free_filename(&old_nm); | 1555 | fscrypt_free_filename(&old_nm); |