All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: arei.gonglei@huawei.com, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, peter.huangpeng@huawei.com,
	stefanha@redhat.com, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 1/4] net/slirp: fix memory leak
Date: Thu, 20 Nov 2014 14:20:21 +0800	[thread overview]
Message-ID: <546D8825.9070907@redhat.com> (raw)
In-Reply-To: <1416463034-8264-2-git-send-email-arei.gonglei@huawei.com>

On 11/20/2014 01:57 PM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> 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 <agraf@suse.de>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  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 <jasowang@redhat.com>

  reply	other threads:[~2014-11-20  6:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20  5:57 [Qemu-devel] [PATCH 0/4] net: fix high impact outstanding defects reported by Coverity arei.gonglei
2014-11-20  5:57 ` [Qemu-devel] [PATCH 1/4] net/slirp: fix memory leak arei.gonglei
2014-11-20  6:20   ` Jason Wang [this message]
2014-11-20 11:50   ` Stefan Hajnoczi
2014-11-20  5:57 ` [Qemu-devel] [PATCH 2/4] net/socket: fix Uninitialized scalar variable arei.gonglei
2014-11-20  6:22   ` Jason Wang
2014-11-20 11:50   ` Stefan Hajnoczi
2014-11-20  5:57 ` [Qemu-devel] [PATCH 3/4] pcnet: fix Negative array index read arei.gonglei
2014-11-20  6:33   ` Jason Wang
2014-11-20  6:36   ` Paolo Bonzini
2014-11-20  6:44     ` Gonglei
2014-11-20  7:08       ` Paolo Bonzini
2014-11-20  7:38         ` Gonglei
2014-11-20 10:03           ` Paolo Bonzini
2014-11-20  5:57 ` [Qemu-devel] [PATCH 4/4] rtl8139: fix Pointer to local outside scope arei.gonglei
2014-11-20  6:29   ` Paolo Bonzini
2014-11-20  6:55     ` Jason Wang
2014-11-20  7:12       ` Gonglei
2014-11-20  7:50         ` Jason Wang
2014-11-20  8:05           ` Gonglei
2014-11-20  8:11             ` Jason Wang
2014-11-20  8:18               ` Gonglei
2014-11-20  8:24                 ` Jason Wang
2014-11-20  8:52                   ` Gonglei
2014-11-20  9:31                   ` Paolo Bonzini
2014-11-20 11:51 ` [Qemu-devel] [PATCH 0/4] net: fix high impact outstanding defects reported by Coverity Stefan Hajnoczi
2014-11-20 11:54   ` Gonglei

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=546D8825.9070907@redhat.com \
    --to=jasowang@redhat.com \
    --cc=agraf@suse.de \
    --cc=arei.gonglei@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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.