]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - lib/scatterlist.c
sgl_alloc_order: fix memory leak
authorDouglas Gilbert <dgilbert@interlog.com>
Thu, 15 Oct 2020 18:57:35 +0000 (14:57 -0400)
committerJens Axboe <axboe@kernel.dk>
Fri, 16 Oct 2020 15:31:09 +0000 (09:31 -0600)
commitb2a182a40278bc5849730e66bca01a762188ed86
tree7c7973081881b7ccd96703ec83c51e2aa026a5c2
parenta48faebe65b0db55a73b9220c3d919eee849bb79
sgl_alloc_order: fix memory leak

sgl_alloc_order() can fail when 'length' is large on a memory
constrained system. When order > 0 it will potentially be
making several multi-page allocations with the later ones more
likely to fail than the earlier one. So it is important that
sgl_alloc_order() frees up any pages it has obtained before
returning NULL. In the case when order > 0 it calls the wrong
free page function and leaks. In testing the leak was
sufficient to bring down my 8 GiB laptop with OOM.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
lib/scatterlist.c