[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/35] libqos/ahci: fix memory management bugs
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 03/35] libqos/ahci: fix memory management bugs |
Date: |
Sat, 4 Jul 2015 02:06:42 -0400 |
There's a handful of trivial bugs in the libqos/ahci functions,
squish them together.
- Zero cached pointers after freeing them
- The Command List Buffer is an array of 32x 32 byte structures, not
32x 8 byte pointers -- it's 1MiB, not 256 bytes. Zero it ALL.
- Free the correct command in ahci_pick_cmd.
Signed-off-by: John Snow <address@hidden>
Message-id: address@hidden
---
tests/libqos/ahci.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 7e17bb6..08e1c98 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -138,12 +138,14 @@ void ahci_clean_mem(AHCIQState *ahci)
for (port = 0; port < 32; ++port) {
if (ahci->port[port].fb) {
ahci_free(ahci, ahci->port[port].fb);
+ ahci->port[port].fb = 0;
}
if (ahci->port[port].clb) {
for (slot = 0; slot < 32; slot++) {
ahci_destroy_command(ahci, port, slot);
}
ahci_free(ahci, ahci->port[port].clb);
+ ahci->port[port].clb = 0;
}
}
}
@@ -252,7 +254,7 @@ void ahci_hba_enable(AHCIQState *ahci)
/* Allocate Memory for the Command List Buffer & FIS Buffer */
/* PxCLB space ... 0x20 per command, as in 4.2.2 p 36 */
ahci->port[i].clb = ahci_alloc(ahci, num_cmd_slots * 0x20);
- qmemset(ahci->port[i].clb, 0x00, 0x100);
+ qmemset(ahci->port[i].clb, 0x00, num_cmd_slots * 0x20);
g_test_message("CLB: 0x%08" PRIx64, ahci->port[i].clb);
ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb);
g_assert_cmphex(ahci->port[i].clb, ==,
@@ -549,7 +551,7 @@ unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port)
if (reg & (1 << j)) {
continue;
}
- ahci_destroy_command(ahci, port, i);
+ ahci_destroy_command(ahci, port, j);
ahci->port[port].next = (j + 1) % 32;
return j;
}
--
2.1.0
- [Qemu-devel] [PULL 00/35] Ide patches, John Snow, 2015/07/04
- [Qemu-devel] [PULL 01/35] ahci: Do not ignore memory access read size, John Snow, 2015/07/04
- [Qemu-devel] [PULL 05/35] ahci: Rename NCQFIS structure fields, John Snow, 2015/07/04
- [Qemu-devel] [PULL 02/35] qtest/ahci: add test_max, John Snow, 2015/07/04
- [Qemu-devel] [PULL 06/35] ahci: use shorter variables, John Snow, 2015/07/04
- [Qemu-devel] [PULL 04/35] qtest/ahci: add port_reset test, John Snow, 2015/07/04
- [Qemu-devel] [PULL 03/35] libqos/ahci: fix memory management bugs,
John Snow <=
- [Qemu-devel] [PULL 07/35] ahci: add ncq_err helper, John Snow, 2015/07/04
- [Qemu-devel] [PULL 08/35] ahci: check for ncq prdtl overflow, John Snow, 2015/07/04
- [Qemu-devel] [PULL 09/35] ahci: separate prdtl from opts, John Snow, 2015/07/04
- [Qemu-devel] [PULL 10/35] ahci: add ncq debug checks, John Snow, 2015/07/04
- [Qemu-devel] [PULL 11/35] ahci: ncq sector count correction, John Snow, 2015/07/04
- [Qemu-devel] [PULL 12/35] ahci/qtest: Execute IDENTIFY prior to data commands, John Snow, 2015/07/04
- [Qemu-devel] [PULL 13/35] libqos/ahci: fix cmd_sanity for ncq, John Snow, 2015/07/04
- [Qemu-devel] [PULL 14/35] libqos/ahci: add NCQ frame support, John Snow, 2015/07/04
- [Qemu-devel] [PULL 17/35] libqos/ahci: set the NCQ tag on command_commit, John Snow, 2015/07/04
- [Qemu-devel] [PULL 15/35] libqos/ahci: edit wait to be ncq aware, John Snow, 2015/07/04