Skip to content

Commit 472dea1

Browse files
Christoph Hellwigtyhicks
authored andcommitted
ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr
Simplify the logic in ecryptfs_setattr by combining the two ATTR_SIZE blocks. This initializes lower_ia before the size check, which is obviously correct as the size check doesn't look at it. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Tyler Hicks <[email protected]>
1 parent b19fe74 commit 472dea1

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

fs/ecryptfs/inode.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -934,16 +934,15 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap,
934934
rc = setattr_prepare(&nop_mnt_idmap, dentry, ia);
935935
if (rc)
936936
goto out;
937-
if (ia->ia_valid & ATTR_SIZE) {
938-
rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
939-
if (rc)
940-
goto out;
941-
}
942937

943938
memcpy(&lower_ia, ia, sizeof(lower_ia));
944939
if (ia->ia_valid & ATTR_FILE)
945940
lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);
946941
if (ia->ia_valid & ATTR_SIZE) {
942+
rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
943+
if (rc)
944+
goto out;
945+
947946
rc = truncate_upper(dentry, ia, &lower_ia);
948947
if (rc < 0)
949948
goto out;

0 commit comments

Comments
 (0)