From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 018696833; Tue, 27 Nov 2018 10:23:41 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 921E62D80D; Tue, 27 Nov 2018 09:23:40 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50406105705A; Tue, 27 Nov 2018 09:23:27 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com Cc: stable@dpdk.org, Maxime Coquelin Date: Tue, 27 Nov 2018 10:23:25 +0100 Message-Id: <20181127092325.25758-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 27 Nov 2018 09:23:40 +0000 (UTC) Subject: [dpdk-dev] [PATCH] vhost: fix possible null pointer dereferencing 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: Tue, 27 Nov 2018 09:23:42 -0000 If mmap() call fails in vhost_user_set_mem_table, dev->mem is set to NULL. If later, qva_to_vva() is called, a segfault occurs. Fixes: 8f972312b8f4 ("vhost: support vhost-user") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 3ea64eba6..c44fef9cc 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -489,6 +489,9 @@ qva_to_vva(struct virtio_net *dev, uint64_t qva, uint64_t *len) struct rte_vhost_mem_region *r; uint32_t i; + if (unlikely(!dev || !dev->mem)) + return 0; + /* Find the region where the address lives. */ for (i = 0; i < dev->mem->nregions; i++) { r = &dev->mem->regions[i]; -- 2.17.2