Skip to content

Commit

Permalink
exfat: fix incorrect update of stream entry in __exfat_truncate()
Browse files Browse the repository at this point in the history
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: 98d9170 ("exfat: add file operations")
Cc: stable@vger.kernel.org # v5.7
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
  • Loading branch information
Namjae Jeon committed Jun 9, 2020
1 parent f341a7d commit 29bbb14
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/exfat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,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) {
Expand Down

0 comments on commit 29bbb14

Please sign in to comment.