From nobody Tue Nov 4 22:05:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897450566172.8017869487387; Fri, 6 Jul 2018 10:17:30 -0700 (PDT) Received: from localhost ([::1]:59009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUML-0002VD-P1 for importer@patchew.org; Fri, 06 Jul 2018 13:17:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK5-0001DR-25 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK3-0000mF-Qz for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:52029) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK3-0000lw-Ju for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:07 -0400 Received: by mail-wm0-x242.google.com with SMTP id s12-v6so15581981wmc.1 for ; Fri, 06 Jul 2018 10:15:07 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zPTghbrp0HF5js7WGB76JabqaXSlrR8gV6l9vjWVj6A=; b=QvSawCmP+vxsVsHA9qdZ2crh9SqEM0sArHAPMvYlcN0Tdlf/U18aOQBHZMRQqF0otx OikTE/xThYMeRZAm6nld6V3261kY8bv/huSp14V4V6Ub1zA7d3A1resV2gk9nsO4mtoA vhmsPobuJ7qoiQV3xy2NOSwINGIxVnG3bEd8XLPy7kAv1v6Du5VXkIj0IxEiExjOy9bT kFZVnPiUnvpJXrO9oM/lsh82ktbxpdxZkEjlbfejaueMJql0534cIsSgdpQMnHyVuFrW zVzc1Y/EEU31NifeY7EwJLDq+dylNsRd2h/uaFiRH/SDf2pXUBG1jbhXQYBAKmiRHcUV ljQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zPTghbrp0HF5js7WGB76JabqaXSlrR8gV6l9vjWVj6A=; b=XOwZ6x5OcLanD95r9hgglqTAPTSKF4PrTIdKwltHh41S+Pg/EdQSrOYJVpmf5v0dZe +VJ20bGfcp2f+Vv0ZLI1iFWvh9YLNafoJNx9h+E0hEBe15Rghw9rDGGZF80D4Qk7G+0d CUJ/nTZxGA2HcyxpPsmmkYVNHbQ5CE7jwVhps8H1QnoIFZICvBIhWr3pG/yicz0G0jv1 PzKNbyJaoSwqmeTbTX1y3o7igGHAZaq+adtvOoznp1S04giHOyXDk+b7mxMes7VwDBYW phEOG0Cu8ybsWVSZC9oyXQ43+13uW+oPPzWJYRcIKd8BNN5VPRSOM/GADatmCIwXg6rH xM8Q== X-Gm-Message-State: APt69E1CQGglJ1Shw247Trr05Qo2W7HkxRHKxOHFh/I+cgW1js1NOiCI CAhPSwR0P8dFYPyh7ejqjmn+Nor8 X-Google-Smtp-Source: AAOMgpfzmGqlDMLpXmUF0rdPYsrnZLv+ruRFIPebT3GSVYPF1qfmj2l8yvhrsvBK5NklQmdToYEJCw== X-Received: by 2002:a1c:f009:: with SMTP id a9-v6mr7303393wmb.104.1530897306390; Fri, 06 Jul 2018 10:15:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:25 +0200 Message-Id: <1530897268-22932-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 5/8] qemu-char: check errno together with ret < 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "xinhua.Cao" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: "xinhua.Cao" 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 Message-Id: <20180704033642.15996-1-caoxinhua@huawei.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Fixes: 9fc53a10f81d3a9027b23fa810147d21be29e614 Signed-off-by: Paolo Bonzini --- 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); =20 - /* free the written msgfds in any cases other than errno=3D=3DEAGA= IN */ - if (EAGAIN !=3D errno && s->write_msgfds_num) { + /* free the written msgfds in any cases + * other than ret < 0 && errno =3D=3D EAGAIN + */ + if (!(ret < 0 && EAGAIN =3D=3D errno) + && s->write_msgfds_num) { g_free(s->write_msgfds); s->write_msgfds =3D 0; s->write_msgfds_num =3D 0; --=20 1.8.3.1