Skip to contentSkip to conversation

chardev/tcp: fix error message double free error

PATCH In review lichun 4 participants 9 messages Jun 21, 2020 – Jul 2, 2020

lore
Share & tools
lore

lichun

author
#0 lore raw

PATCH v2 1/1 chardev/tcp: fix error message double free error

---
 chardev/char-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -1
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                           "Unable to connect character device %s: ",
                           chr->label);
         s->connect_err_reported = true;
+    } else {
+        error_free(err);
     }
     qemu_chr_socket_restart_timer(chr);
 }
@@ -1086,7 +1088,6 @@ 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);
         goto cleanup;
     }
 
Signature · 1 line
2.18.4
#1 lore raw
Quoted 19 lines · lichun
---
 chardev/char-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                           "Unable to connect character device %s: ",
                           chr->label);
         s->connect_err_reported = true;
+    } else {
+        error_free(err);
     }
     qemu_chr_socket_restart_timer(chr);
 }

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 6 lines
chardev/char-socket.c +0 -1
@@ -1086,7 +1088,6 @@ 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);
         goto cleanup;
     }

Since my "Error handling fixes & cleanups" series fixes similar errors. I'm happy to merge this patch along with it. Up to Marc-André.

#2 lore raw

Hi

Quoted 23 lines · Markus Armbruster
Quoted 20 lines · lichun
---
 chardev/char-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                           "Unable to connect character device %s: ",
                           chr->label);
         s->connect_err_reported = true;
+    } else {
+        error_free(err);
     }
     qemu_chr_socket_restart_timer(chr);
 }
@@ -1086,7 +1088,6 @@ static void qemu_chr_socket_connected(QIOTask *task, void *opaque)
     if (qio_task_propagate_error(task, &err)) {
Quoted 8 lines

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 5 lines
chardev/char-socket.c +0 -1
         tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED);
         check_report_connect_error(chr, err);
-        error_free(err);
         goto cleanup;
     }

Since my "Error handling fixes & cleanups" series fixes similar errors. I'm happy to merge this patch along with it. Up to Marc-André.

That would be great, thanks!

#3 lore raw
Quoted 35 lines

Hi

Quoted 23 lines · Markus Armbruster
Quoted 20 lines · lichun

---
  chardev/char-socket.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                             "Unable to connect character device %s: ",
                             chr->label);
           s->connect_err_reported = true;
+    } else {
+        error_free(err);
       }
       qemu_chr_socket_restart_timer(chr);
   }
@@ -1086,7 +1088,6 @@ static void qemu_chr_socket_connected(QIOTask *task, void *opaque)
       if (qio_task_propagate_error(task, &err)) {
Quoted 8 lines

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 5 lines
chardev/char-socket.c +0 -1
           tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED);
           check_report_connect_error(chr, err);
-        error_free(err);
           goto cleanup;
       }

Since my "Error handling fixes & cleanups" series fixes similar errors. I'm happy to merge this patch along with it.  Up to Marc-André.

Quoted 1 line

That would be great, thanks!

Thank you!

Quoted 1 line
Reviewed-by on v2 1/1
#4 lore raw
In reply to lichun
Quoted 19 lines · lichun
---
 chardev/char-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                           "Unable to connect character device %s: ",
                           chr->label);
         s->connect_err_reported = true;
+    } else {
+        error_free(err);
     }
     qemu_chr_socket_restart_timer(chr);
 }

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 6 lines
chardev/char-socket.c +0 -1
@@ -1086,7 +1088,6 @@ 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);
         goto cleanup;
     }

and queued, thanks!

#5 lore raw
Quoted 30 lines · Markus Armbruster
Quoted 19 lines · lichun
---
 chardev/char-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                           "Unable to connect character device %s: ",
                           chr->label);
         s->connect_err_reported = true;
+    } else {
+        error_free(err);
     }
     qemu_chr_socket_restart_timer(chr);
 }

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 6 lines
chardev/char-socket.c +0 -1
@@ -1086,7 +1088,6 @@ 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);
         goto cleanup;
     }
Quoted 2 lines

and queued, thanks!

Can you please add a note to the commit message?

Errors are already freed by error_report_err, so we only need to call error_free when that function is not called.

and Cc qemu-stable? Or I can queue it too since it's chardev stuff.

#6 lore raw
Quoted 34 lines · Markus Armbruster
Quoted 30 lines
Quoted 19 lines · lichun

---
  chardev/char-socket.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                             "Unable to connect character device %s: ",
                             chr->label);
           s->connect_err_reported = true;
+    } else {
+        error_free(err);
       }
       qemu_chr_socket_restart_timer(chr);
   }

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 6 lines
chardev/char-socket.c +0 -1
@@ -1086,7 +1088,6 @@ 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);
           goto cleanup;
       }
Quoted 2 lines

and queued, thanks!

Quoted 6 lines

Can you please add a note to the commit message?

    Errors are already freed by error_report_err, so we only need to call error_free when that function is not called.

and Cc qemu-stable?  Or I can queue it too since it's chardev stuff.

Ok,  I'll post v3.

Quoted 1 line
#7 lore raw
Quoted 34 lines · On 01/07/20 17:12, [email protected] wrote:
Quoted 34 lines · Markus Armbruster
Quoted 32 lines
Quoted 19 lines · lichun

---
  chardev/char-socket.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                             "Unable to connect character device %s: ",
                             chr->label);
           s->connect_err_reported = true;
+    } else {
+        error_free(err);
       }
       qemu_chr_socket_restart_timer(chr);
   }

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 6 lines
chardev/char-socket.c +0 -1
@@ -1086,7 +1088,6 @@ 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);
           goto cleanup;
       }

and queued, thanks!

Quoted 7 lines
Quoted 6 lines

Can you please add a note to the commit message?

    Errors are already freed by error_report_err, so we only need to call error_free when that function is not called.

and Cc qemu-stable?  Or I can queue it too since it's chardev stuff.

Ok,  I'll post v3.

No need for that, thanks! (My message was for Markus).

Paolo

#8 lore raw
In reply to Paolo Bonzini
Quoted 34 lines · Paolo Bonzini
Quoted 30 lines · Markus Armbruster
Quoted 19 lines · lichun
---
 chardev/char-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-socket.c +2 -0
index afebeec5c3..569d54c144 100644
@@ -142,6 +142,8 @@ static void check_report_connect_error(Chardev *chr,
                           "Unable to connect character device %s: ",
                           chr->label);
         s->connect_err_reported = true;
+    } else {
+        error_free(err);
     }
     qemu_chr_socket_restart_timer(chr);
 }

chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1092

Quoted 6 lines
chardev/char-socket.c +0 -1
@@ -1086,7 +1088,6 @@ 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);
         goto cleanup;
     }
Quoted 2 lines

and queued, thanks!

Quoted 6 lines

Can you please add a note to the commit message?

Errors are already freed by error_report_err, so we only need to call error_free when that function is not called.

and Cc qemu-stable? Or I can queue it too since it's chardev stuff.

Done in my tree, expect PR later today.