]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ecryptfs: use ZERO_PAGE instead of allocating zeroed memory in truncate_upper
authorChristoph Hellwig <hch@lst.de>
Wed, 8 Apr 2026 06:06:38 +0000 (08:06 +0200)
committerTyler Hicks <code@tyhicks.com>
Wed, 8 Apr 2026 23:54:03 +0000 (18:54 -0500)
Use the existing pre-zeroed memory instead of allocating a new chunk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tyler Hicks <code@tyhicks.com>
fs/ecryptfs/inode.c

index 695573850569d43e844dac61aebfbb65f64d60b3..daa63b7dd015498fcd1e94899fcdb8e7e5c90fe0 100644 (file)
@@ -771,15 +771,8 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
         */
        num_zeros = PAGE_SIZE - (ia->ia_size & ~PAGE_MASK);
        if (num_zeros) {
-               char *zeros_virt;
-
-               zeros_virt = kzalloc(num_zeros, GFP_KERNEL);
-               if (!zeros_virt) {
-                       rc = -ENOMEM;
-                       goto out;
-               }
-               rc = ecryptfs_write(inode, zeros_virt, ia->ia_size, num_zeros);
-               kfree(zeros_virt);
+               rc = ecryptfs_write(inode, page_address(ZERO_PAGE(0)),
+                               ia->ia_size, num_zeros);
                if (rc) {
                        pr_err("Error attempting to zero out the remainder of the end page on reducing truncate; rc = [%d]\n",
                                rc);