|
|
9ae3a8 |
From 3272771d5dd899876eb8d7ea3af3ed1d2b2472d2 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 10 Sep 2014 11:06:09 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 10/12] ide: Fix segfault when flushing a device that doesn't exist
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1410347169-4368-4-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 60955
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 3/3] ide: Fix segfault when flushing a device that doesn't exist
|
|
|
9ae3a8 |
Bugzilla: 1123372
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit f7f3ff1da0c451befc8d32f977f9c352d1303f40)
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/ide/core.c | 4 +++-
|
|
|
9ae3a8 |
tests/ide-test.c | 14 ++++++++++++++
|
|
|
9ae3a8 |
2 files changed, 17 insertions(+), 1 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/ide/core.c b/hw/ide/core.c
|
|
|
9ae3a8 |
index 0313250..a2947a9 100644
|
|
|
9ae3a8 |
--- a/hw/ide/core.c
|
|
|
9ae3a8 |
+++ b/hw/ide/core.c
|
|
|
9ae3a8 |
@@ -810,7 +810,9 @@ static void ide_flush_cb(void *opaque, int ret)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_acct_done(s->bs, &s->acct);
|
|
|
9ae3a8 |
+ if (s->bs) {
|
|
|
9ae3a8 |
+ bdrv_acct_done(s->bs, &s->acct);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
s->status = READY_STAT | SEEK_STAT;
|
|
|
9ae3a8 |
ide_async_cmd_done(s);
|
|
|
9ae3a8 |
ide_set_irq(s->bus);
|
|
|
9ae3a8 |
diff --git a/tests/ide-test.c b/tests/ide-test.c
|
|
|
9ae3a8 |
index 739d2bf..51f9239 100644
|
|
|
9ae3a8 |
--- a/tests/ide-test.c
|
|
|
9ae3a8 |
+++ b/tests/ide-test.c
|
|
|
9ae3a8 |
@@ -462,6 +462,19 @@ static void test_flush(void)
|
|
|
9ae3a8 |
ide_test_quit();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static void test_flush_nodev(void)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ ide_test_start("");
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* FLUSH CACHE command on device 0*/
|
|
|
9ae3a8 |
+ outb(IDE_BASE + reg_device, 0);
|
|
|
9ae3a8 |
+ outb(IDE_BASE + reg_command, CMD_FLUSH_CACHE);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Just testing that qemu doesn't crash... */
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ide_test_quit();
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
int main(int argc, char **argv)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
const char *arch = qtest_get_arch();
|
|
|
9ae3a8 |
@@ -493,6 +506,7 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
qtest_add_func("/ide/bmdma/teardown", test_bmdma_teardown);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qtest_add_func("/ide/flush", test_flush);
|
|
|
9ae3a8 |
+ qtest_add_func("/ide/flush_nodev", test_flush_nodev);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = g_test_run();
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|