qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Derek Su <dereksu@qnap.com>, qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com, lichun <lichun@ruijie.com.cn>,
	jwsu1986@gmail.com, pbonzini@redhat.com
Subject: Re: [PATCH v1] chardev/char-socket: fix double free of err after socket is disconnected
Date: Wed, 24 Jun 2020 12:12:40 +0200	[thread overview]
Message-ID: <c0bcaab9-9a9f-e8a7-8ae7-e886a44a968e@redhat.com> (raw)
In-Reply-To: <20200624100054.7168-1-dereksu@qnap.com>

On 6/24/20 12:00 PM, Derek Su wrote:
> The err is freed in check_report_connect_error() conditionally,
> calling error_free() directly may lead to a double-free bug.

This seems the same issue Lichun is working on, right?
https://www.mail-archive.com/qemu-devel@nongnu.org/msg714709.html

> 
> Signed-off-by: Derek Su <dereksu@qnap.com>
> ---
>  chardev/char-socket.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index afebeec5c3..a009bed5ee 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -1086,7 +1086,11 @@ static void qemu_chr_socket_connected(QIOTask *task, void *opaque)
>      if (qio_task_propagate_error(task, &err)) {
>          tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED);
>          check_report_connect_error(chr, err);
> -        error_free(err);
> +
> +        if (!s->connect_err_reported) {
> +            error_free(err);
> +        }
> +
>          goto cleanup;
>      }
>  
> 



  reply	other threads:[~2020-06-24 10:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 10:00 [PATCH v1] chardev/char-socket: fix double free of err after socket is disconnected Derek Su
2020-06-24 10:12 ` Philippe Mathieu-Daudé [this message]
2020-06-24 10:18   ` Derek Su

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=c0bcaab9-9a9f-e8a7-8ae7-e886a44a968e@redhat.com \
    --to=philmd@redhat.com \
    --cc=dereksu@qnap.com \
    --cc=jwsu1986@gmail.com \
    --cc=lichun@ruijie.com.cn \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@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).