Skip to contentSkip to conversation

vhost: fix potential null pointer dereference

PATCH Applied Tiwei Bie 2 participants 3 messages Jun 22, 2018 – Jun 23, 2018

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 vhost: fix potential null pointer dereference

Coverity issue: 293097

Fixes d90cf7d111ac ("vhost: support host notifier")
---
 lib/librte_vhost/vhost_user.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_vhost/vhost_user.c +2 -0
index 26cfebec0..bea6a0428 100644
@@ -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);
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Tiwei Bie

Coverity issue: 293097

Fixes d90cf7d111ac ("vhost: support host notifier")
---
  lib/librte_vhost/vhost_user.c | 2 ++
  1 file changed, 2 insertions(+)
lib/librte_vhost/vhost_user.c +0 -0
index 26cfebec0..bea6a0428 100644

lib/librte_vhost/vhost_user.c int vhost_user_host_notifier_ctrl(int vid, bool enable) · line 1837

Quoted 8 lines
lib/librte_vhost/vhost_user.c +2 -0
@@ -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);

Thanks,
Maxime