fs/nls: Fix inconsistency between utf8_to_utf32() and utf32_to_utf8()
Subsystems (2)
PATCH 1/1 fs/nls: Fix inconsistency between utf8_to_utf32() and utf32_to_utf8()
After commit 25524b619029 ("fs/nls: Fix utf16 to utf8 conversion"), the return values of utf8_to_utf32() and utf32_to_utf8() are inconsistent when encountering an error: utf8_to_utf32() returns -1, while utf32_to_utf8() returns errno codes. Fix this inconsistency by modifying utf8_to_utf32() to return errno codes as well.
--- fs/nls/nls_base.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
fs/nls/nls_base.c +7 -4
@@ -67,19 +67,22 @@ int utf8_to_utf32(const u8 *s, int inlen, unicode_t *pu) l &= t->lmask;if (l < t->lval || l >UNICODE_MAX || (l &SURROGATE_MASK ) ==SURROGATE_PAIR ) -return -1 ; +return -EILSEQ ; + *pu = (unicode_t ) l;return nc; }if (inlen <= nc) -return -1 ; +return -EOVERFLOW ; + s++; c = (*s ^0x80 ) &0xFF ;if (c &0xC0 ) -return -1 ; +return -EILSEQ ; + l = (l <<6 ) | c; } -return -1 ; +return -EILSEQ ; }EXPORT_SYMBOL (utf8_to_utf32);
Signature · 1 line
2.39.5
Quoted 5 lines · Armin Wolf
After commit
25524b619029("fs/nls: Fix utf16 to utf8 conversion"), the return values ofutf8_to_utf32()andutf32_to_utf8()are inconsistent when encountering an error:utf8_to_utf32()returns -1, whileutf32_to_utf8()returns errno codes. Fix this inconsistency by modifyingutf8_to_utf32()to return errno codes as well.
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 5 lines · Armin Wolf
After commit
25524b619029("fs/nls: Fix utf16 to utf8 conversion"), the return values ofutf8_to_utf32()andutf32_to_utf8()are inconsistent when encountering an error:utf8_to_utf32()returns -1, whileutf32_to_utf8()returns errno codes. Fix this inconsistency by modifyingutf8_to_utf32()to return errno codes as well.Reviewed-by Andy Shevchenko <[email protected]>Thanks!
Note, you might need a Fixes tag as the original one was marked as Fixes.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Am 26.11.25 um 22:14 schrieb Andy Shevchenko:
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Armin Wolf
Quoted 5 lines
After commit
25524b619029("fs/nls: Fix utf16 to utf8 conversion"), the return values ofutf8_to_utf32()andutf32_to_utf8()are inconsistent when encountering an error:utf8_to_utf32()returns -1, whileutf32_to_utf8()returns errno codes. Fix this inconsistency by modifyingutf8_to_utf32()to return errno codes as well.
Quoted 5 lines
Quoted 3 lines
Reviewed-by Andy Shevchenko <[email protected]>Thanks!
Note, you might need a Fixes tag as the original one was marked as Fixes.
Alright, i will add it in the next patch revision.
Thanks,
Armin Wolf
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Am 26.11.25 um 22:12 schrieb Andy Shevchenko:
Quoted 10 lines · Hans de Goede
Quoted 5 lines
<dropping the lists from the Cc>
Hi Armin,
I think you've gotten the To: and Cc: lists wrong for this one ?
(Semi). The other part of the change is part of pending patches in PDx86. Two options:
- apply now via PDx86 to make it consistent (personally my preference)
- wait for rc1 and push via NLS maintainers / Andrew Morton.
I too would prefer option 1, but i just noticed that get_maintainer.pl does not suggest the VFS maintainers when asking it about fs/nls/nls_base.c. I changed the MAINTAINERS entry for "VFS and infrastructure" from fs/* to fs/ to also include all subdirectories below fs/, and now get_maintainer.pl correctly suggests the VFS maintainers.
Should i send a patch for this too?
Thanks,
Armin Wolf
Quoted 7 lines
Quoted 6 lines · Armin Wolf
Quoted 5 lines
After commit
25524b619029("fs/nls: Fix utf16 to utf8 conversion"), the return values ofutf8_to_utf32()andutf32_to_utf8()are inconsistent when encountering an error:utf8_to_utf32()returns -1, whileutf32_to_utf8()returns errno codes. Fix this inconsistency by modifyingutf8_to_utf32()to return errno codes as well.
Quoted 10 lines · Armin Wolf
Am 26.11.25 um 22:12 schrieb Andy Shevchenko:
Quoted 8 lines · Hans de Goede
Quoted 3 lines
<dropping the lists from the Cc>
I think you've gotten the To: and Cc: lists wrong for this one ?
(Semi). The other part of the change is part of pending patches in PDx86. Two options:
- apply now via PDx86 to make it consistent (personally my preference)
- wait for rc1 and push via NLS maintainers / Andrew Morton.
Quoted 6 lines
I too would prefer option 1, but i just noticed that get_maintainer.pl does not suggest the VFS maintainers when asking it about
fs/nls/nls_base.c. I changed theMAINTAINERSentry for "VFS and infrastructure" fromfs/*tofs/to also include all subdirectories belowfs/, and now get_maintainer.pl correctly suggests the VFS maintainers.Should i send a patch for this too?
I don't think it's a good idea. VFS maintainers won't like to be "spammed" by that. Probably NLS is handled by any maintainer or Andrew Morton, depending on the case. Here we are totally fine to go via PDx86.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Armin Wolf
Quoted 5 lines
After commit
25524b619029("fs/nls: Fix utf16 to utf8 conversion"), the return values ofutf8_to_utf32()andutf32_to_utf8()are inconsistent when encountering an error:utf8_to_utf32()returns -1, whileutf32_to_utf8()returns errno codes. Fix this inconsistency by modifyingutf8_to_utf32()to return errno codes as well.
Signature · 2 lines
With Best Regards, Andy Shevchenko