Skip to content

Commit b19fe74

Browse files
Christoph Hellwigtyhicks
authored andcommitted
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>
1 parent b109187 commit b19fe74

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

fs/ecryptfs/inode.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,15 +771,8 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
771771
*/
772772
num_zeros = PAGE_SIZE - (ia->ia_size & ~PAGE_MASK);
773773
if (num_zeros) {
774-
char *zeros_virt;
775-
776-
zeros_virt = kzalloc(num_zeros, GFP_KERNEL);
777-
if (!zeros_virt) {
778-
rc = -ENOMEM;
779-
goto out;
780-
}
781-
rc = ecryptfs_write(inode, zeros_virt, ia->ia_size, num_zeros);
782-
kfree(zeros_virt);
774+
rc = ecryptfs_write(inode, page_address(ZERO_PAGE(0)),
775+
ia->ia_size, num_zeros);
783776
if (rc) {
784777
pr_err("Error attempting to zero out the remainder of the end page on reducing truncate; rc = [%d]\n",
785778
rc);

0 commit comments

Comments
 (0)