]> Git Repo - linux.git/commitdiff
exfat: fix name_hash computation on big endian systems
authorIlya Ponetayev <[email protected]>
Thu, 16 Jul 2020 08:27:53 +0000 (17:27 +0900)
committerNamjae Jeon <[email protected]>
Tue, 21 Jul 2020 01:44:19 +0000 (10:44 +0900)
On-disk format for name_hash field is LE, so it must be explicitly
transformed on BE system for proper result.

Fixes: 370e812b3ec1 ("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]>
fs/exfat/nls.c

index 57b5a7a4d1f7a18b1854348bd6841ea7bc9c466a..a3c927501e676f3b240eca17106b07a296d99e6f 100644 (file)
@@ -495,7 +495,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb,
                struct exfat_uni_name *p_uniname, int *p_lossy)
 {
        int i, unilen, lossy = NLS_NAME_NO_LOSSY;
-       unsigned short upname[MAX_NAME_LENGTH + 1];
+       __le16 upname[MAX_NAME_LENGTH + 1];
        unsigned short *uniname = p_uniname->name;
 
        WARN_ON(!len);
@@ -519,7 +519,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb,
                    exfat_wstrchr(bad_uni_chars, *uniname))
                        lossy |= NLS_NAME_LOSSY;
 
-               upname[i] = exfat_toupper(sb, *uniname);
+               upname[i] = cpu_to_le16(exfat_toupper(sb, *uniname));
                uniname++;
        }
 
@@ -597,7 +597,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb,
                struct exfat_uni_name *p_uniname, int *p_lossy)
 {
        int i = 0, unilen = 0, lossy = NLS_NAME_NO_LOSSY;
-       unsigned short upname[MAX_NAME_LENGTH + 1];
+       __le16 upname[MAX_NAME_LENGTH + 1];
        unsigned short *uniname = p_uniname->name;
        struct nls_table *nls = EXFAT_SB(sb)->nls_io;
 
@@ -611,7 +611,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb,
                    exfat_wstrchr(bad_uni_chars, *uniname))
                        lossy |= NLS_NAME_LOSSY;
 
-               upname[unilen] = exfat_toupper(sb, *uniname);
+               upname[unilen] = cpu_to_le16(exfat_toupper(sb, *uniname));
                uniname++;
                unilen++;
        }
This page took 0.051545 seconds and 4 git commands to generate.