ahci: fix ncq aiocb-related segfault
cover ahci: fix ncq aiocb-related segfault
Fix ncq_cb to prevent a segfault on sys_reset.
John Snow (1):
ahci: clear aiocb in ncq_cb
hw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)
Signature · 1 line
2.7.4
PATCH 1/1 ahci: clear aiocb in ncq_cb
Similar to existing fixes for IDE and ATAPI, the AIOCB must be cleared in the callback. Otherwise, we may accidentally try to reset it after the object has been released.
--- hw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)
hw/ide/ahci.c +1 -0
@@ -948,6 +948,7 @@ static void ncq_cb(void *opaque, int ret)NCQTransferState *ncq_tfs = (NCQTransferState *)opaque;IDEState *ide_state = &ncq_tfs->drive->port.ifs[0 ]; + ncq_tfs->aiocb =NULL ;if (ret == -ECANCELED ) {return ; }
Signature · 1 line
2.7.4
Quoted 10 lines · John Snow
Fix
ncq_cbto prevent a segfault onsys_reset.John Snow (1):
ahci: clear aiocb inncq_cbhw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)Signature · 1 line
2.7.4
Maybe worth adding as a clarification:
The issue is when bdrv_aio_cancel() is called after ncq_cb() was already invoked. The aiocb will be a dangling pointer.
John Snow
AppliedQuoted 9 lines · Stefan Hajnoczi
Quoted 8 lines · John Snow
Fix
ncq_cbto prevent a segfault onsys_reset.John Snow (1):
ahci: clear aiocb inncq_cbhw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)
Quoted 8 lines
Quoted 2 lines
--
2.7.4Maybe worth adding as a clarification:
The issue is when
bdrv_aio_cancel()is called afterncq_cb()was already invoked. The aiocb will be a dangling pointer.
Done.
Quoted 2 lines
Reviewed-by Stefan Hajnoczi <[email protected]>
Thanks, applied to my IDE tree:
https://github.com/jnsnow/qemu/commits/ide
https://github.com/jnsnow/qemu.git
--js