[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 48/60] ide: Fix crash with too long PRD
From: |
Michael Tokarev |
Subject: |
[Qemu-stable] [PATCH 48/60] ide: Fix crash with too long PRD |
Date: |
Mon, 4 Feb 2013 14:40:58 +0400 |
From: Kevin Wolf <address@hidden>
Without this, s->nsector can become negative and badness happens (trying
to malloc huge amount of memory and glib calls abort())
Signed-off-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
(cherry picked from commit 038268e2e8087ee2fd8987a77ba580e15f14c147)
Signed-off-by: Michael Tokarev <address@hidden>
---
hw/ide/core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 9785d5f..78c869c 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -590,6 +590,7 @@ void ide_dma_cb(void *opaque, int ret)
IDEState *s = opaque;
int n;
int64_t sector_num;
+ bool stay_active = false;
if (ret < 0) {
int op = BM_STATUS_DMA_RETRY;
@@ -605,6 +606,14 @@ void ide_dma_cb(void *opaque, int ret)
}
n = s->io_buffer_size >> 9;
+ if (n > s->nsector) {
+ /* The PRDs were longer than needed for this request. Shorten them so
+ * we don't get a negative remainder. The Active bit must remain set
+ * after the request completes. */
+ n = s->nsector;
+ stay_active = true;
+ }
+
sector_num = ide_get_sector(s);
if (n > 0) {
dma_buf_commit(s);
@@ -657,6 +666,9 @@ eot:
bdrv_acct_done(s->bs, &s->acct);
}
ide_set_inactive(s);
+ if (stay_active) {
+ s->bus->dma->ops->add_status(s->bus->dma, BM_STATUS_DMAING);
+ }
}
static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd)
--
1.7.10.4
- [Qemu-stable] [PATCH 08/60] eepro100: Fix network hang when rx buffers run out, (continued)
- [Qemu-stable] [PATCH 08/60] eepro100: Fix network hang when rx buffers run out, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 53/60] hw/qxl: qxl_send_events: nop if stopped, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 12/60] intel_hda: do not call msi_reset when only device state needs resetting, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 24/60] qxl: always update displaysurface on resize, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 36/60] PPC: Bamboo: Fix memory size DT property, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 17/60] net: notify iothread after flushing queue, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 31/60] linux-user: fix emulation of getdents, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 44/60] qcow2: Fix refcount table size calculation, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 43/60] qcow2: Fix avail_sectors in cluster allocation code, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 06/60] fix doc of using raw values with sendkey, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 48/60] ide: Fix crash with too long PRD,
Michael Tokarev <=
- Re: [Qemu-stable] Patch queue for qemu-1.1.3 stable release, Doug Goldstein, 2013/02/04
- Re: [Qemu-stable] [Qemu-devel] Patch queue for qemu-1.1.3 stable release, Michael Tokarev, 2013/02/19