From 9fa4db44b76716352b994abd7668bc9565466f7f Mon Sep 17 00:00:00 2001 From: tuxoko Date: Mon, 24 Oct 2016 16:41:56 -0700 Subject: [PATCH] Fix cred leak in zpl_fallocate_common This is caught by kmemleak when running compress_004_pos Reviewed-by: Tim Chase Reviewed by: Brian Behlendorf Signed-off-by: Chunwei Chen Closes #5244 Closes #5330 --- module/zfs/zpl_file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c index c8ac7f8a3..2c84d700d 100644 --- a/module/zfs/zpl_file.c +++ b/module/zfs/zpl_file.c @@ -650,8 +650,6 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len) if (mode != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) return (error); - crhold(cr); - if (offset < 0 || len <= 0) return (-EINVAL); @@ -670,6 +668,7 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len) bf.l_len = len; bf.l_pid = 0; + crhold(cr); cookie = spl_fstrans_mark(); error = -zfs_space(ip, F_FREESP, &bf, FWRITE, offset, cr); spl_fstrans_unmark(cookie);