diff options
| author | David Howells <dhowells@redhat.com> | 2026-06-25 15:06:25 +0100 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-07-01 15:26:29 +0200 |
| commit | 72698020e15db16fc141e191b460bc335263b0ad (patch) | |
| tree | bdcce30f443f610ff3328cc5eeefb2689ea89e25 /drivers/gpu/nova-core/fsp/git@git.tavy.me:linux.git | |
| parent | 70531f4f3a143f81baf549da7f59a24a9f87a65c (diff) | |
iov_iter: Fix a memory leak in iov_iter_extract_user_pages()
There's a potential memory leak in callers of iov_iter_extract_user_pages()
whereby if a pages array is allocated in function, it isn't freed before
returning of an error or 0.
Now, it's not a leak per se in iov_iter_extract_user_pages() as, if an
array is allocated, it's returned through *pages, so it's incumbent on the
caller to free it. However, not all callers do.
Fix this by freeing the table and clearing *pages before returning an error
or 0. Note that iov_iter_extract_pages() and its subfunctions are allowed
to return 0 without returning an array (for instance if the iterator count
is 0).
Fixes: 7d58fe731028 ("iov_iter: Add a function to extract a page list from an iterator")
Closes: https://sashiko.dev/#/patchset/20260616100821.2062304-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260625140640.3116900-8-dhowells@redhat.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
cc: Paulo Alcantara <pc@manguebit.org>
cc: Matthew Wilcox <willy@infradead.org>
cc: Christoph Hellwig <hch@infradead.org>
cc: Jens Axboe <axboe@kernel.dk>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'drivers/gpu/nova-core/fsp/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions
