Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
examples/vhost: check memory table query
[ upstream commit 1739f81 ]

This patch fixes unchecked return value for rte_vhost_get_mem_table(),
which is reported by coverity.

Coverity issue: 364233
Fixes: ca059fa ("examples/vhost: demonstrate the new generic APIs")

Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
chenbo-xia authored and steevenlee committed May 8, 2021
1 parent 4245734 commit 1716e66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/vhost/virtio_net.c
Expand Up @@ -23,6 +23,7 @@ vs_vhost_net_setup(struct vhost_dev *dev)
uint16_t i;
int vid = dev->vid;
struct vhost_queue *queue;
int ret;

RTE_LOG(INFO, VHOST_CONFIG,
"setting builtin vhost-user net driver\n");
Expand All @@ -33,7 +34,12 @@ vs_vhost_net_setup(struct vhost_dev *dev)
else
dev->hdr_len = sizeof(struct virtio_net_hdr);

rte_vhost_get_mem_table(vid, &dev->mem);
ret = rte_vhost_get_mem_table(vid, &dev->mem);
if (ret < 0) {
RTE_LOG(ERR, VHOST_CONFIG, "Failed to get "
"VM memory layout for device(%d)\n", vid);
return;
}

dev->nr_vrings = rte_vhost_get_vring_num(vid);
for (i = 0; i < dev->nr_vrings; i++) {
Expand Down

0 comments on commit 1716e66

Please sign in to comment.