Re: [PATCH] udf: Fix to check the return value of load_nls

From: Jan Kara
Date: Tue Mar 19 2019 - 04:53:03 EST


On Mon 18-03-19 21:59:49, Aditya Pakki wrote:
> load_nls may fail and return an error message. The patch checks
> for such a scenario and passes the error upstream.
>
> Signed-off-by: Aditya Pakki <pakki001@xxxxxxx>

Thanks for the patch! But there's other code handling nls_map in
udf_fill_super() which takes care about this situation:

if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
uopt.nls_map = load_nls_default();
if (!uopt.nls_map)
uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
else
udf_debug("Using default NLS map\n");
}

So if we failed to load nls map admin originally requested, we fall back to
a default nls map or just don't load anything. It is questionable whether
we shouldn't fail mount rather than trying to continue with a different nls
map but at this point I don't see a strong reason to change the current
behavior users can depend on...

I've added a comment to udf_parse_options() to explain the code flow.

Honza

> ---
> fs/udf/super.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index ffd8038ff728..1a38271de6d9 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -573,6 +573,8 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
> if (uopt->nls_map)
> unload_nls(uopt->nls_map);
> uopt->nls_map = load_nls(args[0].from);
> + if (!uopt->nls_map)
> + return 0;
> uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
> }
> break;
> --
> 2.17.1
>
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR