diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2013-12-04 05:19:06 -0500 |
---|---|---|
committer | Benjamin LaHaise <bcrl@kvack.org> | 2013-12-06 10:22:55 -0500 |
commit | d1b9432712a25eeb06114fb4b587133525a47de5 (patch) | |
tree | 6bf2e051cdb49ca640340caf3f14b30a5a3a38ab /fs | |
parent | ddb8c45ba15149ebd41d7586261c05f7ca37f9a1 (diff) |
aio: clean up aio ring in the fail path
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/aio.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -316,8 +316,10 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
316 | if (nr_pages > AIO_RING_PAGES) { | 316 | if (nr_pages > AIO_RING_PAGES) { |
317 | ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), | 317 | ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), |
318 | GFP_KERNEL); | 318 | GFP_KERNEL); |
319 | if (!ctx->ring_pages) | 319 | if (!ctx->ring_pages) { |
320 | put_aio_ring_file(ctx); | ||
320 | return -ENOMEM; | 321 | return -ENOMEM; |
322 | } | ||
321 | } | 323 | } |
322 | 324 | ||
323 | ctx->mmap_size = nr_pages * PAGE_SIZE; | 325 | ctx->mmap_size = nr_pages * PAGE_SIZE; |
@@ -594,7 +596,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
594 | aio_nr + nr_events < aio_nr) { | 596 | aio_nr + nr_events < aio_nr) { |
595 | spin_unlock(&aio_nr_lock); | 597 | spin_unlock(&aio_nr_lock); |
596 | err = -EAGAIN; | 598 | err = -EAGAIN; |
597 | goto err; | 599 | goto err_ctx; |
598 | } | 600 | } |
599 | aio_nr += ctx->max_reqs; | 601 | aio_nr += ctx->max_reqs; |
600 | spin_unlock(&aio_nr_lock); | 602 | spin_unlock(&aio_nr_lock); |
@@ -611,6 +613,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
611 | 613 | ||
612 | err_cleanup: | 614 | err_cleanup: |
613 | aio_nr_sub(ctx->max_reqs); | 615 | aio_nr_sub(ctx->max_reqs); |
616 | err_ctx: | ||
617 | aio_free_ring(ctx); | ||
614 | err: | 618 | err: |
615 | free_percpu(ctx->cpu); | 619 | free_percpu(ctx->cpu); |
616 | free_percpu(ctx->reqs.pcpu_count); | 620 | free_percpu(ctx->reqs.pcpu_count); |