Skip to content

Commit

Permalink
configfs: fix memleak in configfs_release_bin_file
Browse files Browse the repository at this point in the history
When reading binary attributes in progress, buffer->bin_buffer is setup in
configfs_read_bin_file() but never freed.

Fixes: 03607ac ("configfs: implement binary attributes")
Signed-off-by: Chung-Chiang Cheng <[email protected]>
[hch: move the vfree rather than duplicating it]
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
shepjeng authored and Christoph Hellwig committed Jun 22, 2021
1 parent 7fe1e79 commit 3c252b0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/configfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,13 @@ static int configfs_release_bin_file(struct inode *inode, struct file *file)
buffer->bin_buffer_size);
}
up_read(&frag->frag_sem);
/* vfree on NULL is safe */
vfree(buffer->bin_buffer);
buffer->bin_buffer = NULL;
buffer->bin_buffer_size = 0;
buffer->needs_read_fill = 1;
}

vfree(buffer->bin_buffer);
buffer->bin_buffer = NULL;
buffer->bin_buffer_size = 0;
buffer->needs_read_fill = 1;

configfs_release(inode, file);
return 0;
}
Expand Down

0 comments on commit 3c252b0

Please sign in to comment.