svm: fix svm queue overwrite while adding 2 elements
Adding two elements to the full svm queue passes exact bounds check, therefore tail gets overwritten w/o any waiting. Fix it with requiring at lease two free slots. Type: fix Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru> Change-Id: I704ee606c47b523952cb965f848339ae1988cb60
This commit is contained in:

committed by
Florin Coras

parent
7f5f21ebc4
commit
eb5a08e91d
@ -323,14 +323,14 @@ svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait)
|
||||
else
|
||||
svm_queue_lock (q);
|
||||
|
||||
if (PREDICT_FALSE (q->cursize + 1 == q->maxsize))
|
||||
if (PREDICT_FALSE (q->cursize + 1 >= q->maxsize))
|
||||
{
|
||||
if (nowait)
|
||||
{
|
||||
svm_queue_unlock (q);
|
||||
return (-2);
|
||||
}
|
||||
while (q->cursize + 1 == q->maxsize)
|
||||
while (q->cursize + 1 >= q->maxsize)
|
||||
svm_queue_wait_inline (q);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user