Skip to content

Commit

Permalink
rpmsg_virtio: add RPMSG_ASSERT to check the virtqueue add error
Browse files Browse the repository at this point in the history
Add RPMSG_ASSERT() to rpmsg_virtio_return_buffer() to check the
possible virtqueue buffer add error.

Signed-off-by: Bowen Wang <[email protected]>
  • Loading branch information
CV-Bowen committed Dec 4, 2023
1 parent b33183f commit 023574d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev,
uint16_t idx)
{
unsigned int role = rpmsg_virtio_get_role(rvdev);
int ret;

BUFFER_INVALIDATE(buffer, len);

Expand All @@ -102,14 +103,16 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev,
/* Initialize buffer node */
vqbuf.buf = buffer;
vqbuf.len = len;
virtqueue_add_buffer(rvdev->rvq, &vqbuf, 0, 1, buffer);
ret = virtqueue_add_buffer(rvdev->rvq, &vqbuf, 0, 1, buffer);
RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add buffer failed\r\n");
}
#endif /*VIRTIO_DEVICE_ONLY*/

#ifndef VIRTIO_DRIVER_ONLY
if (role == RPMSG_REMOTE) {
(void)buffer;
virtqueue_add_consumed_buffer(rvdev->rvq, idx, len);
ret = virtqueue_add_consumed_buffer(rvdev->rvq, idx, len);
RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add consumed buffer failed\r\n");
}
#endif /*VIRTIO_DRIVER_ONLY*/
}
Expand Down

0 comments on commit 023574d

Please sign in to comment.