diff options
-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); |