[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/59] nvdimm: fix header pointer in nvdimm_build_nfi
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 01/59] nvdimm: fix header pointer in nvdimm_build_nfit() |
Date: |
Fri, 8 Jan 2016 17:08:34 +0200 |
From: Haozhong Zhang <address@hidden>
In the current nvdimm_build_nfit(), the pointer 'header' initially equals
to table_data->data + table_data->len. However, the following
g_array_append_vals(table_data, structures->data, structures->len)
may resize and relocate table_data->data[]. Therefore, the usage of 'header'
afterwards may be illegal.
This patch fixes this issue by storing an offset within table_data->data[]
(rather than an address) in 'header'.
Signed-off-by: Haozhong Zhang <address@hidden>
Reviewed-by: Xiao Guangrong <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/acpi/nvdimm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 9534418..df1b176 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -353,16 +353,18 @@ static void nvdimm_build_nfit(GSList *device_list, GArray
*table_offsets,
GArray *table_data, GArray *linker)
{
GArray *structures = nvdimm_build_device_structure(device_list);
- void *header;
+ unsigned int header;
acpi_add_table(table_offsets, table_data);
/* NFIT header. */
- header = acpi_data_push(table_data, sizeof(NvdimmNfitHeader));
+ header = table_data->len;
+ acpi_data_push(table_data, sizeof(NvdimmNfitHeader));
/* NVDIMM device structures. */
g_array_append_vals(table_data, structures->data, structures->len);
- build_header(linker, table_data, header, "NFIT",
+ build_header(linker, table_data,
+ (void *)(table_data->data + header), "NFIT",
sizeof(NvdimmNfitHeader) + structures->len, 1, NULL);
g_array_free(structures, true);
}
--
MST
- [Qemu-devel] [PULL 50/59] pc: acpi: q35: move PCI0._OSC() method into SSDT, (continued)
- [Qemu-devel] [PULL 50/59] pc: acpi: q35: move PCI0._OSC() method into SSDT, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 52/59] pc: acpi: q35: PCST, PCSB opregions and PCIB field into SSDT, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 51/59] pc: acpi: q35: move PCI0 device definition into SSDT, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 53/59] pc: acpi: switch to AML API composed DSDT, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 56/59] Add VMSTATE_STRUCT_VARRAY_KNOWN, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 55/59] i386/pc: expose identifying the floppy controller, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 57/59] migration/virtio: Remove simple .get/.put use, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 58/59] ivshmem: Store file descriptor for vhost-user negotiation, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 59/59] virtio: fix error message for number of queues, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 54/59] pc: acpi: remove unused ASL templates and related blobs/utils, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 01/59] nvdimm: fix header pointer in nvdimm_build_nfit(),
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 02/59] igd-passthrough: fix use of host_pci_config_read, Michael S. Tsirkin, 2016/01/08
- [Qemu-devel] [PULL 03/59] hw/i386: fill in the CENTURY field of the FADT (FACP) ACPI table, Michael S. Tsirkin, 2016/01/08
- Re: [Qemu-devel] [PULL 00/59] acpi dsdt rework, misc fixes, Peter Maydell, 2016/01/08