vhost: fix potential null pointer dereference
authorTiwei Bie <tiwei.bie@intel.com>
Fri, 22 Jun 2018 03:53:05 +0000 (11:53 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 2 Jul 2018 23:35:58 +0000 (01:35 +0200)
Coverity issue: 293097
Fixes: d90cf7d111ac ("vhost: support host notifier")

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/vhost_user.c

index 26cfebe..bea6a04 100644 (file)
@@ -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);