-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtqueue_add_buffer must check that there is room for multiple buffers #368
Conversation
3f8f8d1
to
57e5173
Compare
lib/virtio/virtqueue.c
Outdated
@@ -129,7 +129,7 @@ int virtqueue_add_buffer(struct virtqueue *vq, struct virtqueue_buf *buf_list, | |||
|
|||
needed = readable + writable; | |||
|
|||
VQ_PARAM_CHK(vq == NULL, status, ERROR_VQUEUE_INVLD_PARAM); | |||
VQ_PARAM_CHK(vq < needed, status, ERROR_VQUEUE_INVLD_PARAM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison is not valid, you compare an integer with a structure pointer.
What about following check?
VQ_PARAM_CHK((needed < 1 || needed > vq->vq_free_cnt), status, ERROR_VQUEUE_INVLD_PARAM);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That certainly makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had actually fixed this as follows:
VQ_PARAM_CHK(vq->vq_free_cnt < needed, status, ERROR_VRING_FULL);
Not sure how I truncated vq_free_cnt on my commit.
Ensure there is enough room for all the buffers being added to the vring. Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to go.
Ensure there is enough room for all the buffers being added to the vring.
Signed-off-by: Tammy Leino tammy_leino@mentor.com