xenfb.c: avoid expensive loops when prod <= out_cons
If the frontend sets out_cons to a value higher than out_prod, it will cause xenfb_handle_events to loop about 2^32 times. Avoid that by using better checks at the beginning of the function. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Reported-by: Ling Liu <liuling-it@360.cn>
This commit is contained in:
parent
9027ac50fd
commit
ac0487e1d2
@ -789,8 +789,9 @@ static void xenfb_handle_events(struct XenFB *xenfb)
|
|||||||
|
|
||||||
prod = page->out_prod;
|
prod = page->out_prod;
|
||||||
out_cons = page->out_cons;
|
out_cons = page->out_cons;
|
||||||
if (prod == out_cons)
|
if (prod - out_cons >= XENFB_OUT_RING_LEN) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
xen_rmb(); /* ensure we see ring contents up to prod */
|
xen_rmb(); /* ensure we see ring contents up to prod */
|
||||||
for (cons = out_cons; cons != prod; cons++) {
|
for (cons = out_cons; cons != prod; cons++) {
|
||||||
union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
|
union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
|
||||||
|
Loading…
Reference in New Issue
Block a user