qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] chardev/tcp: fix error message double free error
  2020-06-21 14:53 [PATCH] chardev/tcp: fix error message double free error lichun
@ 2020-06-21 12:35 ` Marc-André Lureau
  2020-06-21 13:47   ` lichun
  0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2020-06-21 12:35 UTC (permalink / raw)
  To: lichun; +Cc: Bonzini, Paolo, qemu-devel, 706701795

Hi

On Sun, Jun 21, 2020 at 10:54 AM lichun <lichun@ruijie.com.cn> wrote:
>
> Signed-off-by: lichun <lichun@ruijie.com.cn>
> ---
>  chardev/char-socket.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index afebeec5c3..3b6c1c5848 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -1086,7 +1086,10 @@ 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 connect_err_reported is true, it means err is already freed */
> +        if (!s->connect_err_reported) {
> +            error_free(err);
> +        }

Good catch (did you find it with a static analysis tool?).

Instead of checking connect_err_reported here, I would rather let
check_report_connect_error() handle error_free(). Can you update the
patch?

thanks

>          goto cleanup;
>      }
>
> --
> 2.18.4
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] chardev/tcp: fix error message double free error
  2020-06-21 12:35 ` Marc-André Lureau
@ 2020-06-21 13:47   ` lichun
  0 siblings, 0 replies; 3+ messages in thread
From: lichun @ 2020-06-21 13:47 UTC (permalink / raw)
  To: marcandre.lureau; +Cc: pbonzini, qemu-devel, 706701795

>Hi
>
>On Sun, Jun 21, 2020 at 10:54 AM lichun <lichun@ruijie.com.cn> wrote:
>>
>> Signed-off-by: lichun <lichun@ruijie.com.cn>
>> ---
>>  chardev/char-socket.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
>> index afebeec5c3..3b6c1c5848 100644
>> --- a/chardev/char-socket.c
>> +++ b/chardev/char-socket.c
>> @@ -1086,7 +1086,10 @@ 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 connect_err_reported is true, it means err is already freed */
>> +        if (!s->connect_err_reported) {
>> +            error_free(err);
>> +        }
>
>Good catch (did you find it with a static analysis tool?). 
Yeah, I find it with gdb.

>
>Instead of checking connect_err_reported here, I would rather let
>check_report_connect_error() handle error_free(). Can you update the
>patch? 
Of course, I will.
>
>thanks
>
>>          goto cleanup;
>>      }
>>
>> --
>> 2.18.4
>>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] chardev/tcp: fix error message double free error
@ 2020-06-21 14:53 lichun
  2020-06-21 12:35 ` Marc-André Lureau
  0 siblings, 1 reply; 3+ messages in thread
From: lichun @ 2020-06-21 14:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, lichun, 706701795, pbonzini

Signed-off-by: lichun <lichun@ruijie.com.cn>
---
 chardev/char-socket.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index afebeec5c3..3b6c1c5848 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1086,7 +1086,10 @@ 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 connect_err_reported is true, it means err is already freed */
+        if (!s->connect_err_reported) {
+            error_free(err);
+        }
         goto cleanup;
     }
 
-- 
2.18.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-21 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-21 14:53 [PATCH] chardev/tcp: fix error message double free error lichun
2020-06-21 12:35 ` Marc-André Lureau
2020-06-21 13:47   ` lichun

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).