nvdimm acpi: fix g_array_free() with NULL pointer
PATCH 1/1 nvdimm acpi: fix g_array_free() with NULL pointer
Unlike g_free(), g_array_free() does not accept a NULL pointer argument. The following error is logged when an nvdimm device is realized:
GLib-CRITICAL **: g_array_free: assertion 'array' failed
--- hw/acpi/nvdimm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/acpi/nvdimm.c +3 -1
@@ -375,7 +375,9 @@ static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf)static void nvdimm_build_fit_buffer (NvdimmFitBuffer *fit_buf) { -g_array_free (fit_buf->fit, true); +if (fit_buf->fit) { +g_array_free (fit_buf->fit, true); + } fit_buf->fit =nvdimm_build_device_structure (); fit_buf->dirty = true; }
Signature · 1 line
2.9.3
Quoted 7 lines · On Wed, 11 Jan 2017 09:44:43 +0000 Stefan Hajnoczi <[email protected]> wrote:
Unlike
g_free(),g_array_free()does not accept a NULL pointer argument. The following error is logged when an nvdimm device is realized:GLib-CRITICAL **:
g_array_free: assertion 'array' failedCc Xiao Guangrong <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 19 lines
--- hw/acpi/nvdimm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/acpi/nvdimm.c +3
-1@@ -375,7 +375,9 @@ static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf)static void nvdimm_build_fit_buffer (NvdimmFitBuffer *fit_buf) { -g_array_free (fit_buf->fit, true); +if (fit_buf->fit) { +g_array_free (fit_buf->fit, true); + } fit_buf->fit =nvdimm_build_device_structure (); fit_buf->dirty = true; }
Stefan Hajnoczi
NAKQuoted 10 lines · Stefan Hajnoczi
Unlike
g_free(),g_array_free()does not accept a NULL pointer argument. The following error is logged when an nvdimm device is realized:GLib-CRITICAL **:
g_array_free: assertion 'array' failedCc Xiao Guangrong <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- hw/acpi/nvdimm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
NACK
Guangrong pointed out this patch is masking another bug. There seems to be a problem with the order in which functions are called when the device is realized.