From: Markus Armbruster <armbru@redhat.com>
To: <arei.gonglei@huawei.com>
Cc: qemu-trivial@nongnu.org, amit.shah@redhat.com,
quintela@redhat.com, qemu-devel@nongnu.org, mrhines@us.ibm.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] rdma: fix memory leak
Date: Tue, 23 Jun 2015 11:20:56 +0200 [thread overview]
Message-ID: <87h9py232f.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <87oak6zxio.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Tue, 23 Jun 2015 09:36:47 +0200")
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.
WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: arei.gonglei@huawei.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 11:20:56 +0200 [thread overview]
Message-ID: <87h9py232f.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <87oak6zxio.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Tue, 23 Jun 2015 09:36:47 +0200")
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.
next prev parent reply other threads:[~2015-06-23 9:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-23 1:02 [Qemu-trivial] [PATCH] rdma: fix memory leak arei.gonglei
2015-06-23 1:02 ` [Qemu-devel] " arei.gonglei
2015-06-23 4:12 ` [Qemu-trivial] " Amit Shah
2015-06-23 4:12 ` [Qemu-devel] " Amit Shah
2015-06-23 7:36 ` [Qemu-trivial] " Markus Armbruster
2015-06-23 7:36 ` Markus Armbruster
2015-06-23 9:20 ` Markus Armbruster [this message]
2015-06-23 9:20 ` Markus Armbruster
2015-06-23 9:32 ` [Qemu-trivial] " Gonglei
2015-06-23 9:32 ` Gonglei
2015-06-23 7:47 ` [Qemu-trivial] " Paolo Bonzini
2015-06-23 7:47 ` [Qemu-devel] " 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=87h9py232f.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=amit.shah@redhat.com \
--cc=arei.gonglei@huawei.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 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.