From: Gonglei <arei.gonglei@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, amit.shah@redhat.com,
quintela@redhat.com, qemu-devel@nongnu.org, mrhines@us.ibm.com
Subject: Re: [Qemu-devel] [PATCH] rdma: fix memory leak
Date: Tue, 23 Jun 2015 17:32:25 +0800 [thread overview]
Message-ID: <558927A9.6000709@huawei.com> (raw)
In-Reply-To: <87h9py232f.fsf@blackfin.pond.sub.org>
On 2015/6/23 17:20, Markus Armbruster wrote:
> Markus Armbruster <armbru@redhat.com> writes:
>
>> <arei.gonglei@huawei.com> writes:
>>
>>> From: Gonglei <arei.gonglei@huawei.com>
>>>
>>> Variable "r" going out of scope leaks the storage
>>> it points to in line 3268.
>>>
>>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>>> ---
>>> migration/rdma.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/migration/rdma.c b/migration/rdma.c
>>> index cf5de7e..de80860 100644
>>> --- a/migration/rdma.c
>>> +++ b/migration/rdma.c
>>> @@ -3262,12 +3262,13 @@ static const QEMUFileOps rdma_write_ops = {
>>>
>>> static void *qemu_fopen_rdma(RDMAContext *rdma, const char *mode)
>>> {
>>> - QEMUFileRDMA *r = g_malloc0(sizeof(QEMUFileRDMA));
>>> + QEMUFileRDMA *r = NULL;
>>
>> Dead initialization, please drop.
>>
>>>
>>> if (qemu_file_mode_is_not_valid(mode)) {
>>> return NULL;
>>> }
>>>
>>> + r = g_malloc0(sizeof(QEMUFileRDMA));
>>> r->rdma = rdma;
>>>
>>> if (mode[0] == 'w') {
>>
>> Looks good otherwise.
>
> Since you're touching this, you could
>
> r = g_new0(QEMUFileRDMA, 1)
>
> See commit 5839e53.
>
I noticed this, but this whole file is using g_malloc, maybe using
another patch fix them is better. This path is just fix memory leak. :)
Regards,
-Gonglei
next prev parent reply other threads:[~2015-06-23 9:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-23 1:02 [Qemu-devel] [PATCH] rdma: fix memory leak arei.gonglei
2015-06-23 4:12 ` Amit Shah
2015-06-23 7:36 ` Markus Armbruster
2015-06-23 9:20 ` Markus Armbruster
2015-06-23 9:32 ` Gonglei [this message]
2015-06-23 7:47 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=558927A9.6000709@huawei.com \
--to=arei.gonglei@huawei.com \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=mrhines@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).