From: Pavel Dovgalyuk Date: Tue, 9 Feb 2021 05:49:30 +0000 (+0300) Subject: char: don't fail when client is not connected X-Git-Tag: v6.0.0-rc0~67^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6585b1627899a3fcaf1cf62bfb659b04371ca9ec;p=thirdparty%2Fqemu.git char: don't fail when client is not connected This patch checks that ioc is not null before using it in tcp socket tcp_chr_add_watch function. The failure occurs in replay mode of the execution, when monitor and serial port are tcp servers, and there are no clients connected to them: -monitor tcp:127.0.0.1:8081,server,nowait -serial tcp:127.0.0.1:8082,server,nowait Signed-off-by: Pavel Dovgalyuk Reviewed-by: Marc-André Lureau Message-Id: <161284977034.741841.12565530923825663110.stgit@pasha-ThinkPad-X280> Signed-off-by: Paolo Bonzini --- diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 9061981f6d3..b7863b8aaef 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -387,6 +387,9 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len) static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond) { SocketChardev *s = SOCKET_CHARDEV(chr); + if (!s->ioc) { + return NULL; + } return qio_channel_create_watch(s->ioc, cond); }