percpu-refcount, aio: use percpu_ref_cancel_init() in ioctx_alloc()
authorTejun Heo <tj@kernel.org>
Sat, 28 Jun 2014 12:10:12 +0000 (08:10 -0400)
committerTejun Heo <tj@kernel.org>
Sat, 28 Jun 2014 12:10:12 +0000 (08:10 -0400)
ioctx_alloc() reaches inside percpu_ref and directly frees
->pcpu_count in its failure path, which is quite gross.  percpu_ref
has been providing a proper interface to do this,
percpu_ref_cancel_init(), for quite some time now.  Let's use that
instead.

This patch doesn't introduce any behavior changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Benjamin LaHaise <bcrl@kvack.org>
Cc: Kent Overstreet <kmo@daterainc.com>
fs/aio.c

index 4f078c054b41608fe3a8ed325c55d59898b049cb..5e0d7f9cb693480f5e214c567585aaa5bdf32792 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -715,8 +715,8 @@ err_ctx:
 err:
        mutex_unlock(&ctx->ring_lock);
        free_percpu(ctx->cpu);
-       free_percpu(ctx->reqs.pcpu_count);
-       free_percpu(ctx->users.pcpu_count);
+       percpu_ref_cancel_init(&ctx->reqs);
+       percpu_ref_cancel_init(&ctx->users);
        kmem_cache_free(kioctx_cachep, ctx);
        pr_debug("error allocating ioctx %d\n", err);
        return ERR_PTR(err);