From: Michael Tokarev <mjt@tls.msk.ru>
To: Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>,
Shannon Zhao <zhaoshenglong@huawei.com>,
qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org,
hangaohuai@huawei.com, peter.huangpeng@huawei.com,
shannon.zhao@linaro.org
Subject: Re: [Qemu-trivial] [PATCH] hw/bt/sdp: Fix resource leak detect by coverity
Date: Sun, 15 Mar 2015 13:23:54 +0300 [thread overview]
Message-ID: <55055DBA.9040804@msgid.tls.msk.ru> (raw)
In-Reply-To: <55054F1D.2080408@redhat.com>
15.03.2015 12:21, Paolo Bonzini wrote:
> On 14/03/2015 11:07, Stefan Weil wrote:
>>
>> This fixes the memory leak, but I still don't understand what is done here.
>> data is allocated, then filled with values, now it is also deallocated.
>> But I'm missing the part where all those data is used.
>
> "data" escapes in record->attribute_list[record->attributes].pair.
>
> The bug is in bt_l2cap_sdp_close_ch which does an invalid free every
> time it frees the first sdp->service_list[i].attribute_list->pair (but
> the qsort could have moved it elsewhere in the list). The right fix is
> to do a separate malloc for each attribute, instead of a single one.
Or, alternatively, to keep this `data' pointer in sdp to use it in
bt_l2cap_sdp_close_ch().
> In any case, it seems simpler to just leave this code aside.
How many times this code is called?
We have many many places in qemu where resources are allocated once
at startup and never freed just because there's no need to.
Thanks,
/mjt
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>,
Shannon Zhao <zhaoshenglong@huawei.com>,
qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org,
hangaohuai@huawei.com, peter.huangpeng@huawei.com,
shannon.zhao@linaro.org
Subject: Re: [Qemu-devel] [PATCH] hw/bt/sdp: Fix resource leak detect by coverity
Date: Sun, 15 Mar 2015 13:23:54 +0300 [thread overview]
Message-ID: <55055DBA.9040804@msgid.tls.msk.ru> (raw)
In-Reply-To: <55054F1D.2080408@redhat.com>
15.03.2015 12:21, Paolo Bonzini wrote:
> On 14/03/2015 11:07, Stefan Weil wrote:
>>
>> This fixes the memory leak, but I still don't understand what is done here.
>> data is allocated, then filled with values, now it is also deallocated.
>> But I'm missing the part where all those data is used.
>
> "data" escapes in record->attribute_list[record->attributes].pair.
>
> The bug is in bt_l2cap_sdp_close_ch which does an invalid free every
> time it frees the first sdp->service_list[i].attribute_list->pair (but
> the qsort could have moved it elsewhere in the list). The right fix is
> to do a separate malloc for each attribute, instead of a single one.
Or, alternatively, to keep this `data' pointer in sdp to use it in
bt_l2cap_sdp_close_ch().
> In any case, it seems simpler to just leave this code aside.
How many times this code is called?
We have many many places in qemu where resources are allocated once
at startup and never freed just because there's no need to.
Thanks,
/mjt
next prev parent reply other threads:[~2015-03-15 10:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-14 9:47 [Qemu-trivial] [PATCH] hw/bt/sdp: Fix resource leak detect by coverity Shannon Zhao
2015-03-14 9:47 ` [Qemu-devel] " Shannon Zhao
2015-03-14 10:07 ` [Qemu-trivial] " Stefan Weil
2015-03-14 10:07 ` Stefan Weil
2015-03-15 9:21 ` [Qemu-trivial] " Paolo Bonzini
2015-03-15 9:21 ` [Qemu-devel] " Paolo Bonzini
2015-03-15 10:23 ` Michael Tokarev [this message]
2015-03-15 10:23 ` Michael Tokarev
2015-03-15 14:11 ` [Qemu-trivial] " Paolo Bonzini
2015-03-15 14:11 ` [Qemu-devel] " Paolo Bonzini
2015-03-16 7:29 ` [Qemu-trivial] " Markus Armbruster
2015-03-16 7:29 ` Markus Armbruster
2015-03-16 8:13 ` [Qemu-trivial] " Paolo Bonzini
2015-03-16 8:13 ` [Qemu-devel] " Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2015-03-14 3:42 [Qemu-trivial] " Shannon Zhao
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=55055DBA.9040804@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=hangaohuai@huawei.com \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=shannon.zhao@linaro.org \
--cc=sw@weilnetz.de \
--cc=zhaoshenglong@huawei.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.