diff mbox series

vhost: fix potential null pointer dereference

Message ID 20180622035305.28412-1-tiwei.bie@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: fix potential null pointer dereference | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tiwei Bie June 22, 2018, 3:53 a.m. UTC
Coverity issue: 293097
Fixes: d90cf7d111ac ("vhost: support host notifier")

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
 lib/librte_vhost/vhost_user.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Maxime Coquelin June 22, 2018, 7:24 a.m. UTC | #1
On 06/22/2018 05:53 AM, Tiwei Bie wrote:
> Coverity issue: 293097
> Fixes: d90cf7d111ac ("vhost: support host notifier")
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>   lib/librte_vhost/vhost_user.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 26cfebec0..bea6a0428 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1830,6 +1830,8 @@ int vhost_user_host_notifier_ctrl(int vid, bool enable)
>   		return -ENOTSUP;
>   
>   	vdpa_dev = rte_vdpa_get_device(did);
> +	if (!vdpa_dev)
> +		return -ENODEV;
>   
>   	RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_vfio_device_fd, -ENOTSUP);
>   	RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP);
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
Maxime Coquelin June 23, 2018, 6:51 a.m. UTC | #2
On 06/22/2018 05:53 AM, Tiwei Bie wrote:
> Coverity issue: 293097
> Fixes: d90cf7d111ac ("vhost: support host notifier")
> 
> Signed-off-by: Tiwei Bie<tiwei.bie@intel.com>
> ---
>   lib/librte_vhost/vhost_user.c | 2 ++
>   1 file changed, 2 insertions(+)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
diff mbox series

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 26cfebec0..bea6a0428 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1830,6 +1830,8 @@  int vhost_user_host_notifier_ctrl(int vid, bool enable)
 		return -ENOTSUP;
 
 	vdpa_dev = rte_vdpa_get_device(did);
+	if (!vdpa_dev)
+		return -ENODEV;
 
 	RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_vfio_device_fd, -ENOTSUP);
 	RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP);