From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id B3D541BADD for ; Fri, 22 Jun 2018 05:53:39 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 20:53:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,255,1526367600"; d="scan'208";a="234623580" Received: from debian.sh.intel.com ([10.67.104.228]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2018 20:53:34 -0700 From: Tiwei Bie To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org Date: Fri, 22 Jun 2018 11:53:05 +0800 Message-Id: <20180622035305.28412-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.0 Subject: [dpdk-dev] [PATCH] vhost: fix potential null pointer dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2018 03:53:40 -0000 Coverity issue: 293097 Fixes: d90cf7d111ac ("vhost: support host notifier") Signed-off-by: Tiwei Bie --- 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); -- 2.17.0