From: P J P <ppandit@redhat.com>
To: Dmitry Fleytman <dmitry@daynix.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Qemu Developers <qemu-devel@nongnu.org>,
Li Qiang <liqiang6-s@360.cn>
Subject: Re: [Qemu-devel] [PATCH v3] scsi: pvscsi: avoid infinite loop while building SG list
Date: Tue, 13 Sep 2016 16:50:58 +0530 (IST) [thread overview]
Message-ID: <alpine.LFD.2.20.1609131632460.29381@wniryva> (raw)
In-Reply-To: <7D125827-164E-43FF-A80F-8B8908D9B2EE@daynix.com>
Hello Dmitry,
+-- On Tue, 13 Sep 2016, Dmitry Fleytman wrote --+
| Better put here:
|
| if(elemcnt++ >= PVSCSI_MAX_SG_ELEM) {
| return;
| }
|
| And ditch additional conditions from while clauses.
| This way you’ll have less compare operations and avoid
| adding the same element twice when leaving because of too long SG list.
Okay.
| Also this is not a good idea to send truncated requests
| when SG list becomes too long. I’d prefer to return error
| code from pvscsi_convert_sglist() and handle it as appropriate.
This could be a separate patch. Should pvscsi_build_sglist() destroy the
sglist on error?
@@ -656,7 +660,9 @@ pvscsi_build_sglist(PVSCSIState *s, PVSCSIRequest *r)
pci_dma_sglist_init(&r->sgl, d, 1);
if (r->req.flags & PVSCSI_FLAG_CMD_WITH_SG_LIST) {
- pvscsi_convert_sglist(r);
+ if (pvscsi_convert_sglist(r) < 0) {
+ qemu_sglist_destroy(&r->sgl);
+ }
} else {
qemu_sglist_add(&r->sgl, r->req.dataAddr, r->req.dataLen);
}
I'll send both patches together once you confirm.
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F
next prev parent reply other threads:[~2016-09-13 11:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 17:53 [Qemu-devel] [PATCH v3] scsi: pvscsi: avoid infinite loop while building SG list P J P
2016-09-13 7:01 ` P J P
2016-09-13 8:54 ` Dmitry Fleytman
2016-09-13 11:20 ` P J P [this message]
2016-09-13 12:00 ` Dmitry Fleytman
2016-09-13 12:53 ` P J P
2016-09-13 13:05 ` Dmitry Fleytman
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=alpine.LFD.2.20.1609131632460.29381@wniryva \
--to=ppandit@redhat.com \
--cc=dmitry@daynix.com \
--cc=liqiang6-s@360.cn \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).