From: Stefan Weil <sw@weilnetz.de>
To: qemu-trivial <qemu-trivial@nongnu.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
"M. Mohan Kumar" <mohan@in.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] hw/9pfs: Fix potential memory leak and avoid reuse of freed memory
Date: Fri, 19 Jul 2013 21:11:05 +0200 [thread overview]
Message-ID: <51E98F49.7010300@weilnetz.de> (raw)
In-Reply-To: <87fvvubt9s.fsf@in.ibm.com>
Am 04.07.2013 10:53, schrieb M. Mohan Kumar:
> Stefan Weil <sw@weilnetz.de> writes:
>
>> The leak was reported by cppcheck.
>>
>> Function proxy_init also calls g_free for ctx->fs_root.
>> Avoid reuse of this memory by setting ctx->fs_root to NULL.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
>> ---
>>
>> Hi,
>>
>> I'm not sure whether ctx->fs_root should also be freed in the error case.
>> Please feel free to modify my patch if needed.
>>
>> Regards
>> Stefan Weil
>>
>> hw/9pfs/virtio-9p-proxy.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
>> index 8ba2959..5f44bb7 100644
>> --- a/hw/9pfs/virtio-9p-proxy.c
>> +++ b/hw/9pfs/virtio-9p-proxy.c
>> @@ -1153,10 +1153,12 @@ static int proxy_init(FsContext *ctx)
>> sock_id = atoi(ctx->fs_root);
>> if (sock_id < 0) {
>> fprintf(stderr, "socket descriptor not initialized\n");
>> + g_free(proxy);
>> return -1;
>> }
>> }
>> g_free(ctx->fs_root);
>> + ctx->fs_root = NULL;
>>
>> proxy->in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
>> proxy->in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
>> --
>> 1.7.10.4
Please add this patch to the qemu-trivial queue:
http://patchwork.ozlabs.org/patch/251666/
Thanks,
Stefan
WARNING: multiple messages have this Message-ID (diff)
From: Stefan Weil <sw@weilnetz.de>
To: qemu-trivial <qemu-trivial@nongnu.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
"M. Mohan Kumar" <mohan@in.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] hw/9pfs: Fix potential memory leak and avoid reuse of freed memory
Date: Fri, 19 Jul 2013 21:11:05 +0200 [thread overview]
Message-ID: <51E98F49.7010300@weilnetz.de> (raw)
In-Reply-To: <87fvvubt9s.fsf@in.ibm.com>
Am 04.07.2013 10:53, schrieb M. Mohan Kumar:
> Stefan Weil <sw@weilnetz.de> writes:
>
>> The leak was reported by cppcheck.
>>
>> Function proxy_init also calls g_free for ctx->fs_root.
>> Avoid reuse of this memory by setting ctx->fs_root to NULL.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
>> ---
>>
>> Hi,
>>
>> I'm not sure whether ctx->fs_root should also be freed in the error case.
>> Please feel free to modify my patch if needed.
>>
>> Regards
>> Stefan Weil
>>
>> hw/9pfs/virtio-9p-proxy.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
>> index 8ba2959..5f44bb7 100644
>> --- a/hw/9pfs/virtio-9p-proxy.c
>> +++ b/hw/9pfs/virtio-9p-proxy.c
>> @@ -1153,10 +1153,12 @@ static int proxy_init(FsContext *ctx)
>> sock_id = atoi(ctx->fs_root);
>> if (sock_id < 0) {
>> fprintf(stderr, "socket descriptor not initialized\n");
>> + g_free(proxy);
>> return -1;
>> }
>> }
>> g_free(ctx->fs_root);
>> + ctx->fs_root = NULL;
>>
>> proxy->in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
>> proxy->in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
>> --
>> 1.7.10.4
Please add this patch to the qemu-trivial queue:
http://patchwork.ozlabs.org/patch/251666/
Thanks,
Stefan
next prev parent reply other threads:[~2013-07-19 19:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-16 10:14 [Qemu-devel] [PATCH] hw/9pfs: Fix potential memory leak and avoid reuse of freed memory Stefan Weil
2013-07-02 20:34 ` Stefan Weil
2013-07-04 8:53 ` M. Mohan Kumar
2013-07-19 19:11 ` Stefan Weil [this message]
2013-07-19 19:11 ` Stefan Weil
2013-07-23 17:09 ` [Qemu-trivial] " Michael Tokarev
2013-07-23 17:09 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
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=51E98F49.7010300@weilnetz.de \
--to=sw@weilnetz.de \
--cc=aliguori@us.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=mohan@in.ibm.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 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.