Re: [f2fs-dev] [PATCH v10 7/8] ext4: Move CONFIG_UNICODE defguards into the code flow

From: Gabriel Krisman Bertazi
Date: Fri Mar 22 2024 - 18:12:00 EST


Eugen Hristev via Linux-f2fs-devel
<linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx> writes:

> From: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxx>
>
> Instead of a bunch of ifdefs, make the unicode built checks part of the
> code flow where possible, as requested by Torvalds.
>
> Reviewed-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxx>
> [eugen.hristev@xxxxxxxxxxxxx: port to 6.8-rc3]
> Signed-off-by: Eugen Hristev <eugen.hristev@xxxxxxxxxxxxx>
> ---
> fs/ext4/crypto.c | 19 +++----------------
> fs/ext4/ext4.h | 33 +++++++++++++++++++++------------
> fs/ext4/namei.c | 14 +++++---------
> fs/ext4/super.c | 4 +---
> 4 files changed, 30 insertions(+), 40 deletions(-)
>
> diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
> index 7ae0b61258a7..1d2f8b79529c 100644
> --- a/fs/ext4/crypto.c
> +++ b/fs/ext4/crypto.c
> @@ -31,12 +31,7 @@ int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname,
>
> ext4_fname_from_fscrypt_name(fname, &name);
>
> -#if IS_ENABLED(CONFIG_UNICODE)
> - err = ext4_fname_setup_ci_filename(dir, iname, fname);
> - if (err)
> - ext4_fname_free_filename(fname);
> -#endif
> - return err;
> + return ext4_fname_setup_ci_filename(dir, iname, fname);

This shouldn't remove the error path. It effectively reintroduces the
memory leak fixed by commit 7ca4b085f430 ("ext4: fix memory leaks in
ext4_fname_{setup_filename,prepare_lookup}").

This patch was only about inlining the codeguards, so it shouldn't be
changing the logic.

> }
>
> int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry,
> @@ -51,12 +46,7 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry,
>
> ext4_fname_from_fscrypt_name(fname, &name);
>
> -#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;
> + return ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname);
> }

likewise


--
Gabriel Krisman Bertazi