]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
exfat: fix incorrect update of stream entry in __exfat_truncate()
authorNamjae Jeon <namjae.jeon@samsung.com>
Wed, 3 Jun 2020 23:05:31 +0000 (08:05 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jun 2020 14:42:59 +0000 (16:42 +0200)
commit 29bbb14bfc80dd760b07d2be0a27e610562982e3 upstream.

At truncate, there is a problem of incorrect updating in the file entry
pointer instead of stream entry. This will cause the problem of
overwriting the time field of the file entry to new_size. Fix it to
update stream entry.

Fixes: 98d917047e8b ("exfat: add file operations")
Cc: stable@vger.kernel.org # v5.7
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/exfat/file.c

index c9db8eb0cfc3ee267d5e3b051974ceae8de861b5..5b4ddff187312e5b24d0f1c17ae79770b2cd9b9b 100644 (file)
@@ -170,11 +170,11 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
 
                /* File size should be zero if there is no cluster allocated */
                if (ei->start_clu == EXFAT_EOF_CLUSTER) {
-                       ep->dentry.stream.valid_size = 0;
-                       ep->dentry.stream.size = 0;
+                       ep2->dentry.stream.valid_size = 0;
+                       ep2->dentry.stream.size = 0;
                } else {
-                       ep->dentry.stream.valid_size = cpu_to_le64(new_size);
-                       ep->dentry.stream.size = ep->dentry.stream.valid_size;
+                       ep2->dentry.stream.valid_size = cpu_to_le64(new_size);
+                       ep2->dentry.stream.size = ep->dentry.stream.valid_size;
                }
 
                if (new_size == 0) {