From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "xinhua.Cao" <caoxinhua@huawei.com>
Cc: pbonzini@redhat.com, marcandre.lureau@redhat.com,
eblake@redhat.com, anton.nefedov@virtuozzo.com,
vsementsov@virtuozzo.com, weidong.huang@huawei.com,
weifuqiang@huawei.com, qemu-devel@nongnu.org,
king.wang@huawei.com, liuyongan@huawei.com,
arei.gonglei@huawei.com
Subject: Re: [Qemu-devel] [PATCH] qemu-char: check errno together with ret < 0
Date: Wed, 4 Jul 2018 10:20:07 +0100 [thread overview]
Message-ID: <20180704092007.GA32267@redhat.com> (raw)
In-Reply-To: <20180704033642.15996-1-caoxinhua@huawei.com>
On Wed, Jul 04, 2018 at 11:36:42AM +0800, xinhua.Cao wrote:
> 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 <caoxinhua@huawei.com>
> ---
> 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;
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2018-07-04 9:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 3:36 [Qemu-devel] [PATCH] qemu-char: check errno together with ret < 0 xinhua.Cao
2018-07-04 9:20 ` Daniel P. Berrangé [this message]
2018-07-04 9:36 ` Marc-André Lureau
2018-07-04 9:38 ` Paolo Bonzini
2018-07-04 11:11 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180704092007.GA32267@redhat.com \
--to=berrange@redhat.com \
--cc=anton.nefedov@virtuozzo.com \
--cc=arei.gonglei@huawei.com \
--cc=caoxinhua@huawei.com \
--cc=eblake@redhat.com \
--cc=king.wang@huawei.com \
--cc=liuyongan@huawei.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
--cc=weidong.huang@huawei.com \
--cc=weifuqiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).