Thread (3 messages) 3 messages, 2 authors, 2021-03-31

Re: [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value

From: Maxime Coquelin <hidden>
Date: 2021-03-19 09:50:55


On 2/19/21 3:40 AM, Chenbo Xia wrote:
quoted hunk ↗ jump to hunk
This patch fixes unchecked return value for rte_vhost_get_mem_table(),
which is reported by coverity.

Coverity issue: 364233
Fixes: ca059fa5e290 ("examples/vhost: demonstrate the new generic APIs")
Cc: stable@dpdk.org

Signed-off-by: Chenbo Xia <redacted>
---
 examples/vhost/virtio_net.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c
index 64bf3d19ff..9064fc3a82 100644
--- a/examples/vhost/virtio_net.c
+++ b/examples/vhost/virtio_net.c
@@ -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");
@@ -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++) {
Reviewed-by: Maxime Coquelin <redacted>

Thanks,
Maxime
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help