From: Gonglei <arei.gonglei@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] ossaudio: fix memory leak
Date: Tue, 23 Jun 2015 16:03:41 +0800 [thread overview]
Message-ID: <558912DD.3060509@huawei.com> (raw)
In-Reply-To: <87si9izxkq.fsf@blackfin.pond.sub.org>
On 2015/6/23 15:35, Markus Armbruster wrote:
> <arei.gonglei@huawei.com> writes:
>
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> Variable "conf" going out of scope leaks the storage
>> it points to in line 856.
>>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>> audio/ossaudio.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
>> index 11e76a1..7dbe333 100644
>> --- a/audio/ossaudio.c
>> +++ b/audio/ossaudio.c
>> @@ -853,6 +853,7 @@ static void *oss_audio_init (void)
> static void *oss_audio_init (void)
> {
> OSSConf *conf = g_malloc(sizeof(OSSConf));
> *conf = glob_conf;
>>
>> if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
>> access(conf->devpath_out, R_OK | W_OK) < 0) {
>> + g_free(conf);
>> return NULL;
>> }
>> return conf;
> }
>
> Simpler (untested):
>
> static void *oss_audio_init (void)
> {
> if (access(globconf.devpath_in, R_OK | W_OK) < 0 ||
> access(globconf.devpath_out, R_OK | W_OK) < 0) {
> return NULL;
> }
> return g_memdup(&glob_conf, sizeof(glob_conf));
> }
>
I think your approach is better :)
Do you want to submit a patch? Or let me post v2 for this?
Regards,
-Gonglei
prev parent reply other threads:[~2015-06-23 8:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-23 1:01 [Qemu-devel] [PATCH] ossaudio: fix memory leak arei.gonglei
2015-06-23 7:35 ` Markus Armbruster
2015-06-23 8:03 ` Gonglei [this message]
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=558912DD.3060509@huawei.com \
--to=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/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).