From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2Gnc-0001sO-FM for qemu-devel@nongnu.org; Wed, 02 Jul 2014 05:26:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2GnT-0005Br-Eb for qemu-devel@nongnu.org; Wed, 02 Jul 2014 05:25:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2GnT-0005Bj-5f for qemu-devel@nongnu.org; Wed, 02 Jul 2014 05:25:47 -0400 Message-ID: <53B3D011.9000200@redhat.com> Date: Wed, 02 Jul 2014 11:25:37 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1404291017-7456-1-git-send-email-arei.gonglei@huawei.com> <53B3CB04.5040909@redhat.com> <53B3CFB8.5000800@huawei.com> In-Reply-To: <53B3CFB8.5000800@huawei.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] ide: fix double free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: ChenLiang Cc: kwolf@redhat.com, arei.gonglei@huawei.com, weidong.huang@huawei.com, qemu-devel@nongnu.org, stefanha@redhat.com Il 02/07/2014 11:24, ChenLiang ha scritto: > On 2014/7/2 17:04, Paolo Bonzini wrote: > >> This is definitely a heavyweight solution, and in fact the bug should >> not be there in the first place. See dma_complete: >> >> static void dma_complete(DMAAIOCB *dbs, int ret) >> { >> trace_dma_complete(dbs, ret, dbs->common.cb); >> >> dma_bdrv_unmap(dbs); >> if (dbs->common.cb) { >> dbs->common.cb(dbs->common.opaque, ret); >> } >> qemu_iovec_destroy(&dbs->iov); >> if (dbs->bh) { >> qemu_bh_delete(dbs->bh); >> dbs->bh = NULL; >> } >> if (!dbs->in_cancel) { >> /* Requests may complete while dma_aio_cancel is in progress. In >> * this case, the AIOCB should not be released because it is still >> * referenced by dma_aio_cancel. */ >> qemu_aio_release(dbs); >> } >> } >> >> Perhaps something like this? >> >> diff --git a/dma-helpers.c b/dma-helpers.c >> index 53cbe92..21b70d12 100644 >> --- a/dma-helpers.c >> +++ b/dma-helpers.c >> @@ -181,15 +181,15 @@ static void dma_aio_cancel(BlockDriverAIOCB *acb) >> >> trace_dma_aio_cancel(dbs); >> >> + dbs->in_cancel = true; >> if (dbs->acb) { >> BlockDriverAIOCB *acb = dbs->acb; >> dbs->acb = NULL; >> - dbs->in_cancel = true; >> bdrv_aio_cancel(acb); >> - dbs->in_cancel = false; >> } >> dbs->common.cb = NULL; >> dma_complete(dbs, 0); >> + qemu_aio_release(dbs); >> } >> >> static const AIOCBInfo dma_aiocb_info = { >> >> >> . >> > > acked, thanks Did you test this? :) What is the testcase? Paolo