examples/vhost: fix unchecked return value
PATCH 1/1 examples/vhost: fix unchecked return value
This patch fixes unchecked return value for rte_vhost_get_mem_table(), which is reported by coverity.
Coverity issue: 364233
--- examples/vhost/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
examples/vhost/virtio_net.c +7 -1
@@ -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++) {
Signature · 1 line
2.17.1
Quoted 29 lines · Chenbo Xia
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")Signed-off-by Chenbo Xia <[email protected]>--- examples/vhost/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)examples/vhost/virtio_net.c +1
-0@@ -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 );
examples/vhost/virtio_net.c vs_vhost_net_setup(struct vhost_dev *dev) · line 45
Quoted 10 lines
examples/vhost/virtio_net.c +6
-1-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++) {
Thanks,
Maxime
Xia, Chenbo
AppliedQuoted 10 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, February 19, 2021 10:40 AM
To: [email protected]
Cc: [email protected]; [email protected]
Subject: [dpdk-dev] [PATCH] examples/vhost: fix unchecked return valueThis patch fixes unchecked return value for
rte_vhost_get_mem_table(), which is reported by coverity.
Quoted 7 lines
Coverity issue: 364233
Fixes ca059fa5e290 ("examples/vhost: demonstrate the new generic APIs")Signed-off-by Chenbo Xia <[email protected]>---
2.17.1
Applied to next-virtio/main, Thanks