Skip to content

Commit

Permalink
configfs: fix memleak in configfs_release_bin_file
Browse files Browse the repository at this point in the history
[ Upstream commit 3c252b0 ]

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 <cccheng@synology.com>
[hch: move the vfree rather than duplicating it]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
shepjeng authored and gregkh committed Jul 14, 2021
1 parent 79b7f7c commit bca193b
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 @@ -482,13 +482,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 bca193b

Please sign in to comment.