diff options
author | Luís Henriques <lhenriques@suse.de> | 2023-08-03 10:17:13 +0100 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-08-05 08:17:56 -0400 |
commit | 7ca4b085f430f3774c3838b3da569ceccd6a0177 (patch) | |
tree | 76fdb5edb74d16c8e44425165cc5bbf2dc333f99 /fs/ext4/crypto.c | |
parent | 5f02a30eac5cc1c081cbdb42d19fd0ded00b0618 (diff) | |
download | linux-7ca4b085f430f3774c3838b3da569ceccd6a0177.tar.gz linux-7ca4b085f430f3774c3838b3da569ceccd6a0177.tar.bz2 linux-7ca4b085f430f3774c3838b3da569ceccd6a0177.zip |
ext4: fix memory leaks in ext4_fname_{setup_filename,prepare_lookup}
If the filename casefolding fails, we'll be leaking memory from the
fscrypt_name struct, namely from the 'crypto_buf.name' member.
Make sure we free it in the error path on both ext4_fname_setup_filename()
and ext4_fname_prepare_lookup() functions.
Cc: stable@kernel.org
Fixes: 1ae98e295fa2 ("ext4: optimize match for casefolded encrypted dirs")
Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20230803091713.13239-1-lhenriques@suse.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/crypto.c')
-rw-r--r-- | fs/ext4/crypto.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index e20ac0654b3f..453d4da5de52 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -33,6 +33,8 @@ int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname, #if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, iname, fname); + if (err) + ext4_fname_free_filename(fname); #endif return err; } @@ -51,6 +53,8 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, #if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); + if (err) + ext4_fname_free_filename(fname); #endif return err; } |