Skip to content
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

Merged
merged 1 commit into from
Apr 14, 2022

Conversation

tammyleino
Copy link
Collaborator

Ensure there is enough room for all the buffers being added to the vring.
Signed-off-by: Tammy Leino tammy_leino@mentor.com

@tammyleino tammyleino force-pushed the openamp_358 branch 3 times, most recently from 3f8f8d1 to 57e5173 Compare April 12, 2022 14:12
@@ -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);
Copy link
Collaborator

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);

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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>
Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@edmooring edmooring left a 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.

@arnopo arnopo merged commit 2dcdc61 into OpenAMP:main Apr 14, 2022
@arnopo arnopo linked an issue Apr 14, 2022 that may be closed by this pull request
@arnopo arnopo added this to the Release V2022.04 milestone Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtqueue_add_buffer returns error if vq->vq_free_cnt != 0
3 participants