From 333f3ae591ee7dd2d746b15696e7a0c551d432fe Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 14 Feb 2012 11:14:22 +0100
Subject: [PATCH 57/99] linux-aio: Fix laio_submit error handling

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1329218101-24213-58-git-send-email-kwolf@redhat.com>
Patchwork-id: 37250
O-Subject: [RHEL-6.3 qemu-kvm PATCH v2 57/96] linux-aio: Fix laio_submit error handling
Bugzilla: 783950
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>

Bugzilla: 783950

The error handling order was in the wrong order, so that either the ACB would
be leaked or the counter would be decremented when it shouldn't.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 449c184ed23c6238da7fcc8b965c8fcc865d72a9)
---
 linux-aio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 linux-aio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-aio.c b/linux-aio.c
index 1af4b49..746a764 100644
--- a/linux-aio.c
+++ b/linux-aio.c
@@ -193,10 +193,10 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
         goto out_dec_count;
     return &laiocb->common;
 
-out_free_aiocb:
-    qemu_aio_release(laiocb);
 out_dec_count:
     s->count--;
+out_free_aiocb:
+    qemu_aio_release(laiocb);
     return NULL;
 }
 
-- 
1.7.7.5

