ide: Fix segfault when flushing a device that doesn't exist
PATCH 1/1 ide: Fix segfault when flushing a device that doesn't exist
Signed-off-by Kevin Wolf <[email protected]>
--- hw/ide/core.c | 4 +++- tests/ide-test.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
hw/ide/core.c +3 -1
@@ -838,7 +838,9 @@ static void ide_flush_cb(void *opaque, int ret) } } -bdrv_acct_done (s->bs, &s->acct); +if (s->bs) { +bdrv_acct_done (s->bs, &s->acct); + } s->status =READY_STAT |SEEK_STAT ;ide_async_cmd_done (s);ide_set_irq (s->bus);
tests/ide-test.c +14 -0
@@ -489,6 +489,19 @@ static void test_flush(void)ide_test_quit (); } +static void test_flush_nodev (void ) +{ +ide_test_start ("" ); + +/* FLUSH CACHE command on device 0*/ +outb (IDE_BASE + reg_device,0 ); +outb (IDE_BASE + reg_command,CMD_FLUSH_CACHE ); + +/* Just testing that qemu doesn't crash... */ + +ide_test_quit (); +} +int main (int argc,char **argv) {const char *arch =qtest_get_arch ();
@@ -521,6 +534,7 @@ int main(int argc, char **argv)qtest_add_func ("/ide/bmdma/teardown" , test_bmdma_teardown);qtest_add_func ("/ide/flush" , test_flush); +qtest_add_func ("/ide/flush_nodev" , test_flush_nodev); ret =g_test_run ();
Signature · 1 line
1.8.3.1
Stefan Hajnoczi
AppliedQuoted 5 lines · Kevin Wolf
Signed-off-by Kevin Wolf <[email protected]>--- hw/ide/core.c | 4 +++- tests/ide-test.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan