qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue
@ 2014-08-30  3:36 john.liuli
  2014-08-30  5:26 ` Michael Tokarev
  0 siblings, 1 reply; 4+ messages in thread
From: john.liuli @ 2014-08-30  3:36 UTC (permalink / raw)
  To: mjt; +Cc: qemu-trivial, Li Liu, qemu-devel

From: Li Liu <john.liuli@huawei.com>

All qerror_report_err returned none NULL pointers need to
be freed, otherwise will cause memory leaking.

Although this place did not cause real memory leaking by exit,
obviously it's not correct to use qerror_report_err
without error_free it.

Signed-off-by: Li Liu <john.liuli@huawei.com>
---
 numa.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/numa.c b/numa.c
index c78cec9..0b4ac9b 100644
--- a/numa.c
+++ b/numa.c
@@ -298,6 +298,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
         MemoryRegion *seg = host_memory_backend_get_memory(backend, &local_err);
         if (local_err) {
             qerror_report_err(local_err);
+            error_free(local_err);
             exit(1);
         }
 
-- 
1.7.9.5

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

* Re: [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue
  2014-08-30  3:36 [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue john.liuli
@ 2014-08-30  5:26 ` Michael Tokarev
  2014-08-30  5:28   ` Gonglei (Arei)
  2014-08-30  6:24   ` Li Liu
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Tokarev @ 2014-08-30  5:26 UTC (permalink / raw)
  To: john.liuli; +Cc: qemu-trivial, qemu-devel

30.08.2014 07:36, john.liuli wrote:
> From: Li Liu <john.liuli@huawei.com>
> 
> All qerror_report_err returned none NULL pointers need to
> be freed, otherwise will cause memory leaking.
> 
> Although this place did not cause real memory leaking by exit,
> obviously it's not correct to use qerror_report_err
> without error_free it.

I don't thing there's any good reason to free resources like
this (freeing memory, closing files, etc) right before exit()
(esp. in error path).  The OS will do that for us in one go
much faster.

/mjt

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

* Re: [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue
  2014-08-30  5:26 ` Michael Tokarev
@ 2014-08-30  5:28   ` Gonglei (Arei)
  2014-08-30  6:24   ` Li Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Gonglei (Arei) @ 2014-08-30  5:28 UTC (permalink / raw)
  To: Michael Tokarev, Liuli (I); +Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org

> -----Original Message-----
> From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
> [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
> Behalf Of Michael Tokarev
> Sent: Saturday, August 30, 2014 1:26 PM
> To: Liuli (I)
> Cc: qemu-trivial@nongnu.org; qemu-devel@nongnu.org
> Subject: Re: [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue
> 
> 30.08.2014 07:36, john.liuli wrote:
> > From: Li Liu <john.liuli@huawei.com>
> >
> > All qerror_report_err returned none NULL pointers need to
> > be freed, otherwise will cause memory leaking.
> >
> > Although this place did not cause real memory leaking by exit,
> > obviously it's not correct to use qerror_report_err
> > without error_free it.
> 
> I don't thing there's any good reason to free resources like
> this (freeing memory, closing files, etc) right before exit()
> (esp. in error path).  The OS will do that for us in one go
> much faster.
> 
Yes. Agreed.

Best regards,
-Gonglei

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

* Re: [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue
  2014-08-30  5:26 ` Michael Tokarev
  2014-08-30  5:28   ` Gonglei (Arei)
@ 2014-08-30  6:24   ` Li Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Li Liu @ 2014-08-30  6:24 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial, qemu-devel



On 2014/8/30 13:26, Michael Tokarev wrote:
> 30.08.2014 07:36, john.liuli wrote:
>> From: Li Liu <john.liuli@huawei.com>
>>
>> All qerror_report_err returned none NULL pointers need to
>> be freed, otherwise will cause memory leaking.
>>
>> Although this place did not cause real memory leaking by exit,
>> obviously it's not correct to use qerror_report_err
>> without error_free it.
> 
> I don't thing there's any good reason to free resources like
> this (freeing memory, closing files, etc) right before exit()
> (esp. in error path).  The OS will do that for us in one go
> much faster.
> 

Yes, the OS will do that for us. But if someone refer to this code
to use qerror_report_err, it will give a bad hint. Of cause this
patch is just a suggestion.

Best regards
Li.

> /mjt
> 
> 

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

end of thread, other threads:[~2014-08-30  6:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-30  3:36 [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue john.liuli
2014-08-30  5:26 ` Michael Tokarev
2014-08-30  5:28   ` Gonglei (Arei)
2014-08-30  6:24   ` Li Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).