chardev/char-socket: fix double free of err after socket is disconnected
PATCH 1/1 chardev/char-socket: fix double free of err after socket is disconnected
The err is freed in check_report_connect_error() conditionally, calling error_free() directly may lead to a double-free bug.
--- chardev/char-socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
chardev/char-socket.c +5 -1
@@ -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; }
Signature · 1 line
2.17.1
Quoted 2 lines · Derek Su
The err is freed in
check_report_connect_error()conditionally, callingerror_free()directly may lead to a double-free bug.
This seems the same issue Lichun is working on, right?
https://www.mail-archive.com/[email protected]/msg714709.html
Quoted 24 lines
Signed-off-by Derek Su <[email protected]>--- chardev/char-socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)chardev/char-socket.c +5
-1@@ -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; }
Oops! Sorry, I dont’t notice this patch before.
Thanks.
Derek
Philippe Mathieu-Daudé <[email protected]>於 2020年6月24日 週三,下午6:12寫道:
Quoted 19 lines · Derek Su
Quoted 2 lines
The err is freed in
check_report_connect_error()conditionally, callingerror_free()directly may lead to a double-free bug.This seems the same issue Lichun is working on, right?
https://www.mail-archive.com/[email protected]/msg714709.htmlchardev/char-socket.c static void qemu_chr_socket_connected(QIOTask
Quoted 11 lines
Signed-off-by Derek Su <[email protected]>--- chardev/char-socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)chardev/char-socket.c +0
-0@@ -1086,7 +1086,11 @@ static void qemu_chr_socket_connected(QIOTask*task, void *opaque)
Quoted 15 lines
chardev/char-socket.c static void qemu_chr_socket_connected(QIOTask *task, void *opaque) · line 1096
Quoted 13 lines
chardev/char-socket.c +5
-1if (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; }--
Best regards,
Derek Su
QNAP Systems, Inc.
Email: [email protected]
Tel: (+886)-2-2393-5152 ext. 15017
Address: 13F., No.56, Sec. 1, Xinsheng S. Rd., Zhongzheng Dist., Taipei City, Taiwan