All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
@ 2017-01-11  9:44 Stefan Hajnoczi
  2017-01-11 16:08 ` Igor Mammedov
  2017-01-12 10:58 ` Stefan Hajnoczi
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2017-01-11  9:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, Michael S. Tsirkin, Stefan Hajnoczi, Xiao Guangrong

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

Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/acpi/nvdimm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 8e7d6ec..8f0a484 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
  2017-01-11  9:44 [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer Stefan Hajnoczi
@ 2017-01-11 16:08 ` Igor Mammedov
  2017-01-12 10:58 ` Stefan Hajnoczi
  1 sibling, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2017-01-11 16:08 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, Xiao Guangrong, Michael S. Tsirkin

On Wed, 11 Jan 2017 09:44:43 +0000
Stefan Hajnoczi <stefanha@redhat.com> 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' failed
> 
> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/acpi/nvdimm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
> index 8e7d6ec..8f0a484 100644
> --- a/hw/acpi/nvdimm.c
> +++ b/hw/acpi/nvdimm.c
> @@ -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;
>  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
  2017-01-11  9:44 [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer Stefan Hajnoczi
  2017-01-11 16:08 ` Igor Mammedov
@ 2017-01-12 10:58 ` Stefan Hajnoczi
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2017-01-12 10:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, Michael S. Tsirkin, Xiao Guangrong

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

On Wed, Jan 11, 2017 at 09:44:43AM +0000, Stefan Hajnoczi 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' failed
> 
> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
  2017-01-12 11:09   ` Stefan Hajnoczi
@ 2017-01-13  0:50     ` Xiao Guangrong
  0 siblings, 0 replies; 7+ messages in thread
From: Xiao Guangrong @ 2017-01-13  0:50 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, imammedo, Michael S. Tsirkin, Zhang, Haozhong


CCed Haozhong

On 01/12/2017 07:09 PM, Stefan Hajnoczi wrote:
> On Thu, Jan 12, 2017 at 11:18:25AM +0800, Xiao Guangrong wrote:
>>
>>
>> On 01/11/2017 05:36 PM, Stefan Hajnoczi 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' failed
>>>
>>> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>>> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>>> ---
>>>  hw/acpi/nvdimm.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> NACK
>
>>>
>>> diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
>>> index 8e7d6ec..8f0a484 100644
>>> --- a/hw/acpi/nvdimm.c
>>> +++ b/hw/acpi/nvdimm.c
>>> @@ -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);
>>> +    }
>>
>> Er, i do not know why it is NULL as we have init-ed it in nvdimm_init_fit_buffer:
>>
>> static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf)
>> {
>>     fit_buf->fit = g_array_new(false, true /* clear */, 1);
>> }
>>
>> And i can not reproduce it on my box, could you share your command line and the
>> based commit id?
>
> Good point, it happens when nvdimm_plug() is called but -M pc,nvdimm is
> missing from the command-line.  This means nvdimm_init_acpi_state() was
> not called by pc_init1():
>
>   $ x86_64-softmmu/qemu-system-x86_64 \
>       -enable-kvm \
>       -m 1G,slots=2,maxmem=16G \
>       -drive if=virtio,file=test.img,format=raw \
>       -object memory-backend-file,id=hostmem0,mem-path=mydimm,share=on,size=8G \
>       -device nvdimm,id=nvdimm0,memdev=hostmem0
>
> Do you want to audit the code to check if anything else misbehaves when
> -device nvdimm is used without -M pc,nvdimm?

Yes. Haozhong will help me to audit the code and fix this crash.

Thanks for your report, Stefan!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
  2017-01-12  3:18 ` Xiao Guangrong
@ 2017-01-12 11:09   ` Stefan Hajnoczi
  2017-01-13  0:50     ` Xiao Guangrong
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2017-01-12 11:09 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: qemu-devel, imammedo, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]

On Thu, Jan 12, 2017 at 11:18:25AM +0800, Xiao Guangrong wrote:
> 
> 
> On 01/11/2017 05:36 PM, Stefan Hajnoczi 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' failed
> > 
> > Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  hw/acpi/nvdimm.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)

NACK

> > 
> > diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
> > index 8e7d6ec..8f0a484 100644
> > --- a/hw/acpi/nvdimm.c
> > +++ b/hw/acpi/nvdimm.c
> > @@ -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);
> > +    }
> 
> Er, i do not know why it is NULL as we have init-ed it in nvdimm_init_fit_buffer:
> 
> static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf)
> {
>     fit_buf->fit = g_array_new(false, true /* clear */, 1);
> }
> 
> And i can not reproduce it on my box, could you share your command line and the
> based commit id?

Good point, it happens when nvdimm_plug() is called but -M pc,nvdimm is
missing from the command-line.  This means nvdimm_init_acpi_state() was
not called by pc_init1():

  $ x86_64-softmmu/qemu-system-x86_64 \
      -enable-kvm \
      -m 1G,slots=2,maxmem=16G \
      -drive if=virtio,file=test.img,format=raw \
      -object memory-backend-file,id=hostmem0,mem-path=mydimm,share=on,size=8G \
      -device nvdimm,id=nvdimm0,memdev=hostmem0

Do you want to audit the code to check if anything else misbehaves when
-device nvdimm is used without -M pc,nvdimm?

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
  2017-01-11  9:36 Stefan Hajnoczi
@ 2017-01-12  3:18 ` Xiao Guangrong
  2017-01-12 11:09   ` Stefan Hajnoczi
  0 siblings, 1 reply; 7+ messages in thread
From: Xiao Guangrong @ 2017-01-12  3:18 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel; +Cc: imammedo, Michael S. Tsirkin



On 01/11/2017 05:36 PM, Stefan Hajnoczi 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' failed
>
> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/acpi/nvdimm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
> index 8e7d6ec..8f0a484 100644
> --- a/hw/acpi/nvdimm.c
> +++ b/hw/acpi/nvdimm.c
> @@ -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);
> +    }

Er, i do not know why it is NULL as we have init-ed it in nvdimm_init_fit_buffer:

static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf)
{
     fit_buf->fit = g_array_new(false, true /* clear */, 1);
}

And i can not reproduce it on my box, could you share your command line and the
based commit id?

Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer
@ 2017-01-11  9:36 Stefan Hajnoczi
  2017-01-12  3:18 ` Xiao Guangrong
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2017-01-11  9:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, Michael S. Tsirkin, Stefan Hajnoczi, Xiao Guangrong

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

Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/acpi/nvdimm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 8e7d6ec..8f0a484 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-13  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11  9:44 [Qemu-devel] [PATCH] nvdimm acpi: fix g_array_free() with NULL pointer Stefan Hajnoczi
2017-01-11 16:08 ` Igor Mammedov
2017-01-12 10:58 ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2017-01-11  9:36 Stefan Hajnoczi
2017-01-12  3:18 ` Xiao Guangrong
2017-01-12 11:09   ` Stefan Hajnoczi
2017-01-13  0:50     ` Xiao Guangrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.