From 3eff71ede6fbd65bbc0a26b75c46616a5bda31ee Mon Sep 17 00:00:00 2001 From: "Hyeongseok.Kim" Date: Wed, 10 Jun 2020 08:23:26 +0900 Subject: [PATCH 1/3] exfat: Set the unused characters of FileName field to the value 0000h Some fsck tool complain that padding part of the FileName field is not set to the value 0000h. So let's maintain filesystem cleaner, as exfat's spec. recommendation. Signed-off-by: Hyeongseok.Kim Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- dir.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dir.c b/dir.c index 039e3b60cf3a..972d976bb19f 100644 --- a/dir.c +++ b/dir.c @@ -426,10 +426,12 @@ static void exfat_init_name_entry(struct exfat_dentry *ep, ep->dentry.name.flags = 0x0; for (i = 0; i < EXFAT_FILE_NAME_LEN; i++) { - ep->dentry.name.unicode_0_14[i] = cpu_to_le16(*uniname); - if (*uniname == 0x0) - break; - uniname++; + if (*uniname != 0x0) { + ep->dentry.name.unicode_0_14[i] = cpu_to_le16(*uniname); + uniname++; + } else { + ep->dentry.name.unicode_0_14[i] = 0x0; + } } } From 7705950daffb2f8d798439636dccc85a52fe7b0d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 11 Jun 2020 11:38:31 +0900 Subject: [PATCH 2/3] exfat: add missing brelse() calls on error paths If the second exfat_get_dentry() call fails then we need to release old_bh before returning. There is a similar bug in exfat_move_file(). Fixes: 5f2aa075070c ("exfat: add inode operations") Reported-by: Markus Elfring Signed-off-by: Dan Carpenter Signed-off-by: Namjae Jeon --- namei.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/namei.c b/namei.c index 917d4e6d9e1a..f278386014d2 100644 --- a/namei.c +++ b/namei.c @@ -1184,10 +1184,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh, §or_old); + if (!epold) + return -EIO; epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh, §or_new); - if (!epold || !epnew) + if (!epnew) { + brelse(old_bh); return -EIO; + } memcpy(epnew, epold, DENTRY_SIZE); exfat_update_bh(sb, new_bh, sync); @@ -1268,10 +1272,14 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh, §or_mov); + if (!epmov) + return -EIO; epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh, §or_new); - if (!epmov || !epnew) + if (!epnew) { + brelse(mov_bh); return -EIO; + } memcpy(epnew, epmov, DENTRY_SIZE); exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode)); From 859f93608575d8dd714b84d16f64bf40ee3af26b Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sat, 13 Jun 2020 08:23:54 +0900 Subject: [PATCH 3/3] exfat: add exfat version cat /sys/module/exfat/version 5.8.1 Signed-off-by: Namjae Jeon --- exfat_fs.h | 2 ++ super.c | 1 + 2 files changed, 3 insertions(+) diff --git a/exfat_fs.h b/exfat_fs.h index 59fbfa3d737b..b6ad9dd3b23d 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -11,6 +11,8 @@ #include #include +#define EXFAT_VERSION "5.8.1" + #define EXFAT_SUPER_MAGIC 0x2011BAB0UL #define EXFAT_ROOT_INO 1 diff --git a/super.c b/super.c index 860b40c8f6b0..5cbc2707b7b0 100644 --- a/super.c +++ b/super.c @@ -1077,3 +1077,4 @@ MODULE_ALIAS_FS("exfat"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("exFAT filesystem support"); MODULE_AUTHOR("Samsung Electronics Co., Ltd."); +MODULE_VERSION(EXFAT_VERSION);