qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>, qemu-trivial@nongnu.org
Cc: qemu-devel@nongnu.org, stefanha@redhat.com, peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH] l2tpv3: fix possible double free
Date: Fri, 14 Nov 2014 09:45:36 +0100	[thread overview]
Message-ID: <5465C130.1090401@redhat.com> (raw)
In-Reply-To: <1415929163-12184-1-git-send-email-zhang.zhanghailiang@huawei.com>



On 14/11/2014 02:39, zhanghailiang wrote:
> freeaddrinfo(result) does not assign result = NULL, after frees it.
> There will be a double free when it goes error case.
> It is reported by covertiy.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>  net/l2tpv3.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/l2tpv3.c b/net/l2tpv3.c
> index 528d95b..f9e0c98 100644
> --- a/net/l2tpv3.c
> +++ b/net/l2tpv3.c
> @@ -661,6 +661,7 @@ int net_init_l2tpv3(const NetClientOptions *opts,
>          fd = -errno;
>          error_report("l2tpv3_open : socket creation failed, errno = %d", -fd);
>          freeaddrinfo(result);
> +        result = NULL;

You can just remove the call to freeaddrinfo().  I made the change and
applied the patch.

Paolo

>          goto outerr;
>      }
>      if (bind(fd, (struct sockaddr *) result->ai_addr, result->ai_addrlen)) {
> 

  parent reply	other threads:[~2014-11-14  8:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14  1:39 [Qemu-devel] [PATCH] l2tpv3: fix possible double free zhanghailiang
2014-11-14  3:03 ` Gonglei
2014-11-14  8:45 ` Paolo Bonzini [this message]
2014-11-17  5:13   ` zhanghailiang

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=5465C130.1090401@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhang.zhanghailiang@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 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).