diff mbox series

[v1,1/2] exfat: fix setting uninitialized time to ctime/atime

Message ID PUZPR04MB63163B71EB1474935175FCC181A6A@PUZPR04MB6316.apcprd04.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/2] exfat: fix setting uninitialized time to ctime/atime | expand

Commit Message

Yuezhang.Mo@sony.com Nov. 2, 2023, 6:10 a.m. UTC
An uninitialized time is set to ctime/atime in __exfat_write_inode().
It causes xfstests generic/003 and generic/192 to fail.

And since there will be a time gap between setting ctime/atime to
the inode and writing back the inode, so ctime/atime should not be
set again when writing back the inode.

Fixes: 4c72a36edd54 ("exfat: convert to new timestamp accessors")

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>

---
 fs/exfat/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 875234179d1f..e7ff58b8e68c 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -56,18 +56,18 @@  int __exfat_write_inode(struct inode *inode, int sync)
 			&ep->dentry.file.create_time,
 			&ep->dentry.file.create_date,
 			&ep->dentry.file.create_time_cs);
+	ts = inode_get_mtime(inode);
 	exfat_set_entry_time(sbi, &ts,
 			     &ep->dentry.file.modify_tz,
 			     &ep->dentry.file.modify_time,
 			     &ep->dentry.file.modify_date,
 			     &ep->dentry.file.modify_time_cs);
-	inode_set_mtime_to_ts(inode, ts);
+	ts = inode_get_atime(inode);
 	exfat_set_entry_time(sbi, &ts,
 			     &ep->dentry.file.access_tz,
 			     &ep->dentry.file.access_time,
 			     &ep->dentry.file.access_date,
 			     NULL);
-	inode_set_atime_to_ts(inode, ts);
 
 	/* File size should be zero if there is no cluster allocated */
 	on_disk_size = i_size_read(inode);