[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] net/slirp: fix memory leak
From: |
Jason Wang |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] net/slirp: fix memory leak |
Date: |
Thu, 20 Nov 2014 14:20:21 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
On 11/20/2014 01:57 PM, address@hidden wrote:
> From: Gonglei <address@hidden>
>
> commit b412eb61 introduce 'cmd:' target for guestfwd,
> and fwd don't be used in this scenario, and will leak
> memory in true branch with 'cmd:'. Let's allocate memory
> for fwd variable just in else statement.
>
> Cc: Alexander Graf <address@hidden>
> Signed-off-by: Gonglei <address@hidden>
> ---
> net/slirp.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/slirp.c b/net/slirp.c
> index dc89e6b..377d7ef 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -643,17 +643,16 @@ static int slirp_guestfwd(SlirpState *s, const char
> *config_str,
> goto fail_syntax;
> }
>
> - fwd = g_malloc(sizeof(struct GuestFwd));
> snprintf(buf, sizeof(buf), "guestfwd.tcp.%d", port);
>
> if ((strlen(p) > 4) && !strncmp(p, "cmd:", 4)) {
> if (slirp_add_exec(s->slirp, 0, &p[4], &server, port) < 0) {
> error_report("conflicting/invalid host:port in guest forwarding "
> "rule '%s'", config_str);
> - g_free(fwd);
> return -1;
> }
> } else {
> + fwd = g_malloc(sizeof(struct GuestFwd));
> fwd->hd = qemu_chr_new(buf, p, NULL);
> if (!fwd->hd) {
> error_report("could not open guest forwarding device '%s'", buf);
Reviewed-by: Jason Wang <address@hidden>
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, (continued)
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, Gonglei, 2014/11/20
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, Jason Wang, 2014/11/20
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, Gonglei, 2014/11/20
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, Jason Wang, 2014/11/20
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, Gonglei, 2014/11/20
- Re: [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope, Paolo Bonzini, 2014/11/20
[Qemu-devel] [PATCH 2/4] net/socket: fix Uninitialized scalar variable, arei.gonglei, 2014/11/20
[Qemu-devel] [PATCH 1/4] net/slirp: fix memory leak, arei.gonglei, 2014/11/20
Re: [Qemu-devel] [PATCH 0/4] net: fix high impact outstanding defects reported by Coverity, Stefan Hajnoczi, 2014/11/20