lkml.org 
[lkml]   [2015]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 3/3] aio_free_ring: don't do page_count(NULL)
Date
Oleg Nesterov <oleg@redhat.com> writes:

> aio_free_ring() can actually see the NULL page in ->ring_pages[],
> this can happen if aio_setup_ring() fails.
>
> And in this case page_count(ctx->ring_pages[i]) can OOPS.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

I'm not sure the reformatting was necessary, but whatever.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

> ---
> fs/aio.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index b605ab2..666fbb8 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -292,12 +292,12 @@ static void aio_free_ring(struct kioctx *ctx)
> put_aio_ring_file(ctx);
>
> for (i = 0; i < ctx->nr_pages; i++) {
> - struct page *page;
> - pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i,
> - page_count(ctx->ring_pages[i]));
> - page = ctx->ring_pages[i];
> + struct page *page = ctx->ring_pages[i];
> if (!page)
> continue;
> +
> + pr_debug("pid(%d) [%d] page->count=%d\n",
> + current->pid, i, page_count(page));
> ctx->ring_pages[i] = NULL;
> put_page(page);
> }


\
 
 \ /
  Last update: 2015-06-17 20:41    [W:0.205 / U:1.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site