From patchwork Sun Oct 28 01:08:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 47537 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 777F94F98; Sun, 28 Oct 2018 02:09:12 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A819D4CC3; Sun, 28 Oct 2018 02:09:08 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Oct 2018 17:09:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,434,1534834800"; d="scan'208";a="101253962" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.212]) by fmsmga004.fm.intel.com with ESMTP; 27 Oct 2018 17:09:06 -0700 From: Ferruh Yigit To: Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: dev@dpdk.org, Ferruh Yigit , stable@dpdk.org Date: Sun, 28 Oct 2018 01:08:46 +0000 Message-Id: <20181028010846.81730-3-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181028010846.81730-1-ferruh.yigit@intel.com> References: <20181028010846.81730-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH 3/3] vhost: fix possible out of bound access 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fixes: d7280c9fffcb ("vhost: support selective datapath") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit Reviewed-by: Maxime Coquelin --- lib/librte_vhost/vdpa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c index c2c5dff1d..e7d849ee0 100644 --- a/lib/librte_vhost/vdpa.c +++ b/lib/librte_vhost/vdpa.c @@ -63,6 +63,9 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr, break; } + if (i == MAX_VHOST_DEVICE) + return -1; + sprintf(device_name, "vdpa-dev-%d", i); dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device), RTE_CACHE_LINE_SIZE);