DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value
@ 2021-02-19  2:40 Chenbo Xia
  2021-03-19  9:50 ` Maxime Coquelin
  2021-03-31  6:56 ` Xia, Chenbo
  0 siblings, 2 replies; 3+ messages in thread
From: Chenbo Xia @ 2021-02-19  2:40 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, stable

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 <chenbo.xia@intel.com>
---
 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++) {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value
  2021-02-19  2:40 [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value Chenbo Xia
@ 2021-03-19  9:50 ` Maxime Coquelin
  2021-03-31  6:56 ` Xia, Chenbo
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2021-03-19  9:50 UTC (permalink / raw)
  To: Chenbo Xia, dev; +Cc: stable



On 2/19/21 3:40 AM, Chenbo Xia wrote:
> 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 <chenbo.xia@intel.com>
> ---
>  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 <maxime.coquelin@redhat.com>

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value
  2021-02-19  2:40 [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value Chenbo Xia
  2021-03-19  9:50 ` Maxime Coquelin
@ 2021-03-31  6:56 ` Xia, Chenbo
  1 sibling, 0 replies; 3+ messages in thread
From: Xia, Chenbo @ 2021-03-31  6:56 UTC (permalink / raw)
  To: Xia, Chenbo, dev; +Cc: maxime.coquelin, stable

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Chenbo Xia
> Sent: Friday, February 19, 2021 10:40 AM
> To: dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] 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
> Fixes: ca059fa5e290 ("examples/vhost: demonstrate the new generic APIs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
> ---
> 2.17.1

Applied to next-virtio/main, Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-31  6:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19  2:40 [dpdk-dev] [PATCH] examples/vhost: fix unchecked return value Chenbo Xia
2021-03-19  9:50 ` Maxime Coquelin
2021-03-31  6:56 ` Xia, Chenbo

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git