aio: don't bother with async freeing on failure in ioctx_alloc()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 6 Mar 2012 19:33:22 +0000 (14:33 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 21 Mar 2012 01:29:38 +0000 (21:29 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/aio.c

index b9d64d89a0437aa4db5b26bf07e1ecb870d6fba1..d09b56090aa5e7d1a2a9d60999b2a1048f539162 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -248,6 +248,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
        struct mm_struct *mm;
        struct kioctx *ctx;
        int did_sync = 0;
+       int err = -ENOMEM;
 
        /* Prevent overflows */
        if ((nr_events > (0x10000000U / sizeof(struct io_event))) ||
@@ -310,16 +311,13 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
        return ctx;
 
 out_cleanup:
-       __put_ioctx(ctx);
-       return ERR_PTR(-EAGAIN);
-
+       err = -EAGAIN;
+       aio_free_ring(ctx);
 out_freectx:
        mmdrop(mm);
        kmem_cache_free(kioctx_cachep, ctx);
-       ctx = ERR_PTR(-ENOMEM);
-
-       dprintk("aio: error allocating ioctx %p\n", ctx);
-       return ctx;
+       dprintk("aio: error allocating ioctx %d\n", err);
+       return ERR_PTR(err);
 }
 
 /* aio_cancel_all