]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lib: kunit_iov_iter: fix memory leaks
authorChristian A. Ehrhardt <lk@c--e.de>
Thu, 26 Mar 2026 21:49:03 +0000 (22:49 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 3 Apr 2026 06:36:23 +0000 (23:36 -0700)
commit0b49c7d0ae697fcecd7377cb7dda220f7cd096ff
tree4c8aedf7c57d11827a26f6827f16fa8eca88d41f
parent118cf3f55975352ac357fb194405031458186819
lib: kunit_iov_iter: fix memory leaks

Use vfree() instead of vunmap() to free the buffer allocated by
iov_kunit_create_buffer() because vunmap() does not honour
VM_MAP_PUT_PAGES.  In order for this to work the page array itself must
not be managed by kunit.

Remove the folio_put() when destroying a folioq.  This is handled by
vfree(), now.

Pointed out by sashiko.dev on a previous iteration of this series.

Tested by running the kunit test 10000 times in a loop.

Link: https://lkml.kernel.org/r/20260326214905.818170-4-lk@c--e.de
Fixes: 2d71340ff1d4 ("iov_iter: Kunit tests for copying to/from an iterator")
Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
Cc: David Howells <dhowells@redhat.com>
Cc: David Gow <davidgow@google.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Petr Mladek <pmladek@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/tests/kunit_iov_iter.c