numa: fix qerror_report_err not free issue
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
@@ -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
Quoted 8 lines · john.liuli
From: Li Liu <[email protected]>
All
qerror_report_errreturned 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_errwithouterror_freeit.
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
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: fixqerror_report_errnot free issueQuoted 5 lines · john.liuli
From: Li Liu <[email protected]>
All
qerror_report_errreturned 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_errwithouterror_freeit.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
Quoted 6 lines · Michael Tokarev
Quoted 5 lines · john.liuli
From: Li Liu <[email protected]>
All
qerror_report_errreturned 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_errwithouterror_freeit.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