mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
fs/ntfs3: handle attr_set_size() errors when truncating files
[ Upstream commit576248a34b] If attr_set_size() fails while truncating down, the error is silently ignored and the inode may be left in an inconsistent state. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Stable-dep-of:d7ea8495fd("fs/ntfs3: fix missing run load for vcn0 in attr_data_get_block_locked()") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
caa36a91c9
commit
92300ac7ff
+4
-6
@@ -371,8 +371,8 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
|
||||
{
|
||||
struct super_block *sb = inode->i_sb;
|
||||
struct ntfs_inode *ni = ntfs_i(inode);
|
||||
int err, dirty = 0;
|
||||
u64 new_valid;
|
||||
int err;
|
||||
|
||||
if (!S_ISREG(inode->i_mode))
|
||||
return 0;
|
||||
@@ -388,7 +388,6 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
|
||||
}
|
||||
|
||||
new_valid = ntfs_up_block(sb, min_t(u64, ni->i_valid, new_size));
|
||||
|
||||
truncate_setsize(inode, new_size);
|
||||
|
||||
ni_lock(ni);
|
||||
@@ -402,20 +401,19 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
|
||||
ni->i_valid = new_valid;
|
||||
|
||||
ni_unlock(ni);
|
||||
if (unlikely(err))
|
||||
return err;
|
||||
|
||||
ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
inode->i_mtime = inode_set_ctime_current(inode);
|
||||
if (!IS_DIRSYNC(inode)) {
|
||||
dirty = 1;
|
||||
mark_inode_dirty(inode);
|
||||
} else {
|
||||
err = ntfs_sync_inode(inode);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (dirty)
|
||||
mark_inode_dirty(inode);
|
||||
|
||||
/*ntfs_flush_inodes(inode->i_sb, inode, NULL);*/
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user