From: Paolo Bonzini <pbonzini@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
"xinhua.Cao" <caoxinhua@huawei.com>
Cc: Eric Blake <eblake@redhat.com>,
Anton Nefedov <anton.nefedov@virtuozzo.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
weidong.huang@huawei.com, weifuqiang@huawei.com,
QEMU <qemu-devel@nongnu.org>,
king.wang@huawei.com, liuyongan@huawei.com,
Gonglei <arei.gonglei@huawei.com>
Subject: Re: [Qemu-devel] [PATCH] qemu-char: check errno together with ret < 0
Date: Wed, 4 Jul 2018 11:38:58 +0200 [thread overview]
Message-ID: <98094b22-7a90-10e0-45d5-1f8ba312b1cb@redhat.com> (raw)
In-Reply-To: <CAJ+F1CKTPE+gKbR5sHvRFxcMnN4ToxxhMoQzeZVcnri+WJVyow@mail.gmail.com>
On 04/07/2018 11:36, Marc-André Lureau wrote:
> On Wed, Jul 4, 2018 at 5:36 AM, xinhua.Cao <caoxinhua@huawei.com> 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>
>
>
> Can you point out this is fixing commit
> 9fc53a10f81d3a9027b23fa810147d21be29e614 in commit message?
Ok, done.
Thanks,
Paolo
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.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;
>> --
>> 2.8.3
>>
>>
>>
>
>
>
next prev parent reply other threads:[~2018-07-04 9:39 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é
2018-07-04 9:36 ` Marc-André Lureau
2018-07-04 9:38 ` Paolo Bonzini [this message]
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=98094b22-7a90-10e0-45d5-1f8ba312b1cb@redhat.com \
--to=pbonzini@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@gmail.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).