btrfs: fix fscrypt name leak after failure to join log transaction

commit fee4c19937 upstream.

When logging a new name, we don't expect to fail joining a log transaction
since we know at least one of the inodes was logged before in the current
transaction. However if we fail for some unexpected reason, we end up not
freeing the fscrypt name we previously allocated. So fix that by freeing
the name in case we failed to join a log transaction.

Fixes: ab3c5c18e8 ("btrfs: setup qstr from dentrys using fscrypt helper")
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Filipe Manana 2022-12-20 11:13:33 +00:00 committed by Greg Kroah-Hartman
parent 6d05a1a7a4
commit 6cd57f5c77

View file

@ -7491,8 +7491,11 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
* not fail, but if it does, it's not serious, just bail out and
* mark the log for a full commit.
*/
if (WARN_ON_ONCE(ret < 0))
if (WARN_ON_ONCE(ret < 0)) {
fscrypt_free_filename(&fname);
goto out;
}
log_pinned = true;
path = btrfs_alloc_path();