* [PATCH] sgl_alloc_order: memory leak
@ 2020-09-20 5:36 Douglas Gilbert
2020-09-20 15:29 ` Bart Van Assche
0 siblings, 1 reply; 2+ messages in thread
From: Douglas Gilbert @ 2020-09-20 5:36 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-block, axboe
Noticed that when sgl_alloc_order() failed with order > 0 that
free memory on my machine shrank. That function shouldn't call
sgl_free() on its error path since that is only correct when
order==0 .
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
---
lib/scatterlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 5d63a8857f36..c448642e0f78 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -514,7 +514,7 @@ struct scatterlist *sgl_alloc_order(unsigned long long length,
elem_len = min_t(u64, length, PAGE_SIZE << order);
page = alloc_pages(gfp, order);
if (!page) {
- sgl_free(sgl);
+ sgl_free_order(sgl, order);
return NULL;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] sgl_alloc_order: memory leak
2020-09-20 5:36 [PATCH] sgl_alloc_order: memory leak Douglas Gilbert
@ 2020-09-20 15:29 ` Bart Van Assche
0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2020-09-20 15:29 UTC (permalink / raw)
To: Douglas Gilbert, linux-kernel; +Cc: linux-block, axboe
On 2020-09-19 22:36, Douglas Gilbert wrote:
> Noticed that when sgl_alloc_order() failed with order > 0 that
> free memory on my machine shrank. That function shouldn't call
> sgl_free() on its error path since that is only correct when
> order==0 .
>
> Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
> ---
> lib/scatterlist.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
> index 5d63a8857f36..c448642e0f78 100644
> --- a/lib/scatterlist.c
> +++ b/lib/scatterlist.c
> @@ -514,7 +514,7 @@ struct scatterlist *sgl_alloc_order(unsigned long long length,
> elem_len = min_t(u64, length, PAGE_SIZE << order);
> page = alloc_pages(gfp, order);
> if (!page) {
> - sgl_free(sgl);
> + sgl_free_order(sgl, order);
> return NULL;
> }
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-20 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-20 5:36 [PATCH] sgl_alloc_order: memory leak Douglas Gilbert
2020-09-20 15:29 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox