Fix cred leak in zpl_fallocate_common

This is caught by kmemleak when running compress_004_pos

Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #5244
Closes #5330
This commit is contained in:
tuxoko 2016-10-24 16:41:56 -07:00 committed by Brian Behlendorf
parent ffcd0c5434
commit 734e235f67
1 changed files with 1 additions and 2 deletions

View File

@ -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)) if (mode != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return (error); return (error);
crhold(cr);
if (offset < 0 || len <= 0) if (offset < 0 || len <= 0)
return (-EINVAL); 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_len = len;
bf.l_pid = 0; bf.l_pid = 0;
crhold(cr);
cookie = spl_fstrans_mark(); cookie = spl_fstrans_mark();
error = -zfs_space(ip, F_FREESP, &bf, FWRITE, offset, cr); error = -zfs_space(ip, F_FREESP, &bf, FWRITE, offset, cr);
spl_fstrans_unmark(cookie); spl_fstrans_unmark(cookie);