From: Christoph Hellwig Date: Wed, 8 Apr 2026 06:06:39 +0000 (+0200) Subject: ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr X-Git-Tag: v7.1-rc1~77^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=472dea1d2235439c0c25850d53deffc517cc8c61;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Tyler Hicks --- diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index daa63b7dd015..ec6aae5af1f8 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -934,16 +934,15 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap, rc = setattr_prepare(&nop_mnt_idmap, dentry, ia); if (rc) goto out; - if (ia->ia_valid & ATTR_SIZE) { - rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size); - if (rc) - goto out; - } memcpy(&lower_ia, ia, sizeof(lower_ia)); if (ia->ia_valid & ATTR_FILE) lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file); if (ia->ia_valid & ATTR_SIZE) { + rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size); + if (rc) + goto out; + rc = truncate_upper(dentry, ia, &lower_ia); if (rc < 0) goto out;