aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/ide/core.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 9d687a9d80..2e0971ddeb 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2727,6 +2727,7 @@ static int ide_drive_post_load(void *opaque, int version_id)
static void ide_drive_pre_save(void *opaque)
{
IDEState *s = opaque;
+ int idx;
s->cur_io_buffer_len = 0;
@@ -2736,11 +2737,13 @@ static void ide_drive_pre_save(void *opaque)
s->cur_io_buffer_offset = s->data_ptr - s->io_buffer;
s->cur_io_buffer_len = s->data_end - s->data_ptr;
- s->end_transfer_fn_idx = transfer_end_table_idx(s->end_transfer_func);
- if (s->end_transfer_fn_idx == -1) {
+ idx = transfer_end_table_idx(s->end_transfer_func);
+ if (idx == -1) {
fprintf(stderr, "%s: invalid end_transfer_func for DRQ_STAT\n",
__func__);
s->end_transfer_fn_idx = 2;
+ } else {
+ s->end_transfer_fn_idx = idx;
}
}