Skip to content

Commit db415f7

Browse files
instenamjaejeon
authored andcommitted
exfat: fix name_hash computation on big endian systems
On-disk format for name_hash field is LE, so it must be explicitly transformed on BE system for proper result. Fixes: 370e812 ("exfat: add nls operations") Cc: [email protected] # v5.7 Signed-off-by: Chen Minqiang <[email protected]> Signed-off-by: Ilya Ponetayev <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 41e3928 commit db415f7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/exfat/nls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb,
495495
struct exfat_uni_name *p_uniname, int *p_lossy)
496496
{
497497
int i, unilen, lossy = NLS_NAME_NO_LOSSY;
498-
unsigned short upname[MAX_NAME_LENGTH + 1];
498+
__le16 upname[MAX_NAME_LENGTH + 1];
499499
unsigned short *uniname = p_uniname->name;
500500

501501
WARN_ON(!len);
@@ -519,7 +519,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb,
519519
exfat_wstrchr(bad_uni_chars, *uniname))
520520
lossy |= NLS_NAME_LOSSY;
521521

522-
upname[i] = exfat_toupper(sb, *uniname);
522+
upname[i] = cpu_to_le16(exfat_toupper(sb, *uniname));
523523
uniname++;
524524
}
525525

@@ -597,7 +597,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb,
597597
struct exfat_uni_name *p_uniname, int *p_lossy)
598598
{
599599
int i = 0, unilen = 0, lossy = NLS_NAME_NO_LOSSY;
600-
unsigned short upname[MAX_NAME_LENGTH + 1];
600+
__le16 upname[MAX_NAME_LENGTH + 1];
601601
unsigned short *uniname = p_uniname->name;
602602
struct nls_table *nls = EXFAT_SB(sb)->nls_io;
603603

@@ -611,7 +611,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb,
611611
exfat_wstrchr(bad_uni_chars, *uniname))
612612
lossy |= NLS_NAME_LOSSY;
613613

614-
upname[unilen] = exfat_toupper(sb, *uniname);
614+
upname[unilen] = cpu_to_le16(exfat_toupper(sb, *uniname));
615615
uniname++;
616616
unilen++;
617617
}

0 commit comments

Comments
 (0)