From: Kevin Wolf Date: Tue, 4 May 2010 14:35:24 +0000 (+0200) Subject: ide: Fix ide_dma_cancel X-Git-Tag: v0.12.5~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df631629b1a80bb890290bdeb3d9fc6c5bedbe5b;p=thirdparty%2Fqemu.git ide: Fix ide_dma_cancel When cancelling a request, bdrv_aio_cancel may decide that it waits for completion of a request rather than for cancellation. IDE therefore can't abandon its DMA status before calling bdrv_aio_cancel; otherwise the callback of a completed request would use invalid data. Signed-off-by: Kevin Wolf (cherry picked from commit 38d8dfa193e9a45f0f08b06aab2ba2a94f40a041) --- diff --git a/hw/ide/core.c b/hw/ide/core.c index 64aebc27649..f9bb338772a 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2827,10 +2827,6 @@ static void ide_dma_restart(IDEState *s, int is_read) void ide_dma_cancel(BMDMAState *bm) { if (bm->status & BM_STATUS_DMAING) { - bm->status &= ~BM_STATUS_DMAING; - /* cancel DMA request */ - bm->unit = -1; - bm->dma_cb = NULL; if (bm->aiocb) { #ifdef DEBUG_AIO printf("aio_cancel\n"); @@ -2838,6 +2834,10 @@ void ide_dma_cancel(BMDMAState *bm) bdrv_aio_cancel(bm->aiocb); bm->aiocb = NULL; } + bm->status &= ~BM_STATUS_DMAING; + /* cancel DMA request */ + bm->unit = -1; + bm->dma_cb = NULL; } }