Skip to content

Commit

Permalink
Fix cred leak in zpl_fallocate_common
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tuxoko authored and behlendorf committed Feb 3, 2017
1 parent ffcd0c5 commit 734e235
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions module/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 734e235

Please sign in to comment.