Blame 0008-ide-ahci-reset-ncq-object-to-unused-on-error.patch

b24b7f
From: Prasad J Pandit <pjp@fedoraproject.org>
b24b7f
Date: Mon, 11 Jan 2016 14:10:42 -0500
b24b7f
Subject: [PATCH] ide: ahci: reset ncq object to unused on error
b24b7f
b24b7f
When processing NCQ commands, AHCI device emulation prepares a
b24b7f
NCQ transfer object; To which an aio control block(aiocb) object
b24b7f
is assigned in 'execute_ncq_command'. In case, when the NCQ
b24b7f
command is invalid, the 'aiocb' object is not assigned, and NCQ
b24b7f
transfer object is left as 'used'. This leads to a use after
b24b7f
free kind of error in 'bdrv_aio_cancel_async' via 'ahci_reset_port'.
b24b7f
Reset NCQ transfer object to 'unused' to avoid it.
b24b7f
b24b7f
[Maintainer edit: s/ACHI/AHCI/ in the commit message. --js]
b24b7f
b24b7f
Reported-by: Qinghao Tang <luodalongde@gmail.com>
b24b7f
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
b24b7f
Reviewed-by: John Snow <jsnow@redhat.com>
b24b7f
Message-id: 1452282511-4116-1-git-send-email-ppandit@redhat.com
b24b7f
Signed-off-by: John Snow <jsnow@redhat.com>
b24b7f
(cherry picked from commit 4ab0359a8ae182a7ac5c99609667273167703fab)
b24b7f
---
b24b7f
 hw/ide/ahci.c | 1 +
b24b7f
 1 file changed, 1 insertion(+)
b24b7f
b24b7f
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
b24b7f
index dd1912e..17f1cbd 100644
b24b7f
--- a/hw/ide/ahci.c
b24b7f
+++ b/hw/ide/ahci.c
b24b7f
@@ -910,6 +910,7 @@ static void ncq_err(NCQTransferState *ncq_tfs)
b24b7f
     ide_state->error = ABRT_ERR;
b24b7f
     ide_state->status = READY_STAT | ERR_STAT;
b24b7f
     ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag);
b24b7f
+    ncq_tfs->used = 0;
b24b7f
 }
b24b7f
 
b24b7f
 static void ncq_finish(NCQTransferState *ncq_tfs)