summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortuxoko <[email protected]>2016-10-24 16:41:56 -0700
committerBrian Behlendorf <[email protected]>2017-02-03 10:24:38 -0800
commit734e235f67e78ba3bbac9b39bc1430e66ff29bbd (patch)
treeb1d303ccee936f23eac371936a8bf52fd545066f
parentffcd0c5434d652326723b6bc302090329d5704e4 (diff)
Fix cred leak in zpl_fallocate_common
This is caught by kmemleak when running compress_004_pos Reviewed-by: Tim Chase <[email protected]> Reviewed by: Brian Behlendorf <[email protected]> Signed-off-by: Chunwei Chen <[email protected]> Closes #5244 Closes #5330
-rw-r--r--module/zfs/zpl_file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
index ccb8f8103..b22ec046e 100644
--- a/module/zfs/zpl_file.c
+++ b/module/zfs/zpl_file.c
@@ -658,8 +658,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);
@@ -678,6 +676,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);