[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/8] qemu-char: check errno together with ret < 0
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 5/8] qemu-char: check errno together with ret < 0 |
Date: |
Fri, 6 Jul 2018 19:14:25 +0200 |
From: "xinhua.Cao" <address@hidden>
In the tcp_chr_write function, we checked errno,
but errno was not reset before a read or write operation.
Therefore, this check of errno's actions is often
incorrect after EAGAIN has occurred.
we need check errno together with ret < 0.
Signed-off-by: xinhua.Cao <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Fixes: 9fc53a10f81d3a9027b23fa810147d21be29e614
Signed-off-by: Paolo Bonzini <address@hidden>
---
chardev/char-socket.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 17519ec..efbad6e 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -134,8 +134,11 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf,
int len)
s->write_msgfds,
s->write_msgfds_num);
- /* free the written msgfds in any cases other than errno==EAGAIN */
- if (EAGAIN != errno && s->write_msgfds_num) {
+ /* free the written msgfds in any cases
+ * other than ret < 0 && errno == EAGAIN
+ */
+ if (!(ret < 0 && EAGAIN == errno)
+ && s->write_msgfds_num) {
g_free(s->write_msgfds);
s->write_msgfds = 0;
s->write_msgfds_num = 0;
--
1.8.3.1
- [Qemu-devel] [PULL 0/8] Bug fixes for 2018-07-06, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 4/8] i386: fix '-cpu ?' output for host cpu type, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 1/8] pr-helper: avoid error on PR IN command with zero request size, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 3/8] qtest: Use cpu address space instead of system memory, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 2/8] pr-helper: Rework socket path handling, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 5/8] qemu-char: check errno together with ret < 0,
Paolo Bonzini <=
- [Qemu-devel] [PULL 6/8] pr-manager-helper: fix memory leak on event, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 8/8] checkpatch: handle token pasting better, Paolo Bonzini, 2018/07/06
- [Qemu-devel] [PULL 7/8] ioapic: remove useless lower bounds check, Paolo Bonzini, 2018/07/06
- Re: [Qemu-devel] [PULL 0/8] Bug fixes for 2018-07-06, Peter Maydell, 2018/07/06