Skip to content

Commit

Permalink
aio: clean up aio ring in the fail path
Browse files Browse the repository at this point in the history
Clean up the aio ring file in the fail path of aio_setup_ring
and ioctx_alloc. And maybe it can fix the GPF issue reported by
Dave Jones:
https://lkml.org/lkml/2013/11/25/898

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
  • Loading branch information
Gu Zheng authored and Benjamin LaHaise committed Dec 6, 2013
1 parent ddb8c45 commit d1b9432
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,10 @@ static int aio_setup_ring(struct kioctx *ctx)
if (nr_pages > AIO_RING_PAGES) {
ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
GFP_KERNEL);
if (!ctx->ring_pages)
if (!ctx->ring_pages) {
put_aio_ring_file(ctx);
return -ENOMEM;
}
}

ctx->mmap_size = nr_pages * PAGE_SIZE;
Expand Down Expand Up @@ -594,7 +596,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
aio_nr + nr_events < aio_nr) {
spin_unlock(&aio_nr_lock);
err = -EAGAIN;
goto err;
goto err_ctx;
}
aio_nr += ctx->max_reqs;
spin_unlock(&aio_nr_lock);
Expand All @@ -611,6 +613,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)

err_cleanup:
aio_nr_sub(ctx->max_reqs);
err_ctx:
aio_free_ring(ctx);
err:
free_percpu(ctx->cpu);
free_percpu(ctx->reqs.pcpu_count);
Expand Down

0 comments on commit d1b9432

Please sign in to comment.