summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-04-08 09:06:38 +0300
committerTyler Hicks <code@tyhicks.com>2026-04-09 02:54:03 +0300
commitb19fe74e0fc970cef90bb78ddb473ae0356bce94 (patch)
tree7fce1dd48514904eee11da7a810c29bfca73fd34
parentb109187378615e683d8d8a24f4bc246bd3fb7b26 (diff)
downloadlinux-b19fe74e0fc970cef90bb78ddb473ae0356bce94.tar.xz
ecryptfs: use ZERO_PAGE instead of allocating zeroed memory in truncate_upper
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>
-rw-r--r--fs/ecryptfs/inode.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 695573850569..daa63b7dd015 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -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);