diff mbox series

btrfs: Fix an error handling path in btrfs_rename()

Message ID 943f0f360f221da954f5dd7f16e366d0e294ae72.1670876024.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New, archived
Headers show
Series btrfs: Fix an error handling path in btrfs_rename() | expand

Commit Message

Christophe JAILLET Dec. 12, 2022, 8:14 p.m. UTC
If new_whiteout_inode() fails, some resources need to be freed.
Add the missing goto to the error handling path.

Fixes: ab3c5c18e8fa ("btrfs: setup qstr from dentrys using fscrypt helper")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 fs/btrfs/inode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Sweet Tea Dorminy Dec. 12, 2022, 8:19 p.m. UTC | #1
On 12/12/22 15:14, Christophe JAILLET wrote:
> If new_whiteout_inode() fails, some resources need to be freed.
> Add the missing goto to the error handling path.
> 
> Fixes: ab3c5c18e8fa ("btrfs: setup qstr from dentrys using fscrypt helper")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>

Thanks for catching this.
David Sterba Dec. 13, 2022, 6:41 p.m. UTC | #2
On Mon, Dec 12, 2022 at 09:14:17PM +0100, Christophe JAILLET wrote:
> If new_whiteout_inode() fails, some resources need to be freed.
> Add the missing goto to the error handling path.
> 
> Fixes: ab3c5c18e8fa ("btrfs: setup qstr from dentrys using fscrypt helper")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8bcad9940154..2ead7b1bdbaf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9377,8 +9377,10 @@  static int btrfs_rename(struct user_namespace *mnt_userns,
 
 	if (flags & RENAME_WHITEOUT) {
 		whiteout_args.inode = new_whiteout_inode(mnt_userns, old_dir);
-		if (!whiteout_args.inode)
-			return -ENOMEM;
+		if (!whiteout_args.inode) {
+			ret = -ENOMEM;
+			goto out_fscrypt_names;
+		}
 		ret = btrfs_new_inode_prepare(&whiteout_args, &trans_num_items);
 		if (ret)
 			goto out_whiteout_inode;