Skip to contentSkip to conversation

numa: fix qerror_report_err not free issue

PATCH In review john.liuli 3 participants 4 messages Aug 30, 2014

lore
Share & tools
lore

john.liuli

author
#0 lore raw

PATCH 1/1 numa: fix qerror_report_err not free issue

From: Li Liu <[email protected]>

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.

---
 numa.c |    1 +
 1 file changed, 1 insertion(+)
numa.c +1 -0
index c78cec9..0b4ac9b 100644
@@ -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);
         }
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 8 lines · john.liuli

From: Li Liu <[email protected]>

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

#2 lore raw
Quoted 15 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Michael Tokarev
Sent: Saturday, August 30, 2014 1:26 PM
To: Liuli (I)
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH] numa: fix qerror_report_err not free issue

Quoted 5 lines · john.liuli

From: Li Liu <[email protected]>

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

Quoted 9 lines
Quoted 3 lines

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

author
#3 lore raw
In reply to Michael Tokarev
Quoted 6 lines · Michael Tokarev
Quoted 5 lines · john.liuli

From: Li Liu <[email protected]>

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

Quoted 9 lines
Quoted 3 lines

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.

Quoted 3 lines

/mjt