> -----Original Message-----
> From: Maxime Coquelin <[email protected]>
> Sent: Wednesday, September 23, 2020 5:22 PM
> To: Fu, Patrick <[email protected]>; [email protected]; Xia, Chenbo
> <[email protected]>
> Cc: Wang, Zhihong <[email protected]>; Jiang, Cheng1
> <[email protected]>
> Subject: Re: [PATCH v1 3/4] vhost: fix async vec buf overrun
>
> s/buf/buffer/
>
> On 9/11/20 3:53 AM, Patrick Fu wrote:
> > Add check on the async vec buffer usage to prevent the buf overrun.
>
> s/vec/vector/
>
> s/buf/buffer/
>
>
> > If vec buf is not sufficient to prepare for next packet's iov
>
> same here
>
Fix in v2
> > if (pkt_burst_idx >= VHOST_ASYNC_BATCH_THRESHOLD ||
> > - (pkt_idx == count - 1 && pkt_burst_idx)) {
> > + (pkt_idx == count - 1 && pkt_burst_idx) ||
> > + VHOST_MAX_ASYNC_VEC / 2 - segs_await <
> > + BUF_VECTOR_MAX) {
>
> Parenthesis may help.
>
> Or better to refactor the code for better readability.
>
Refactor the code seems to be a little bit tricky. I will add parenthesis
together with some comments to improve readability.
Thanks,
Patrick