From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id C954C23B for ; Mon, 22 May 2017 08:42:29 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2017 23:42:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,377,1491289200"; d="scan'208";a="105311229" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga006.fm.intel.com with ESMTP; 21 May 2017 23:42:28 -0700 Date: Mon, 22 May 2017 14:37:59 +0800 From: Yuanhan Liu To: Maxime Coquelin Cc: Jens Freimann , dev@dpdk.org Message-ID: <20170522063759.GN2276@yliu-dev> References: <20170511152526.18379-1-jfreimann@redhat.com> <60b35110-df0e-f42b-c331-709b6435f737@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60b35110-df0e-f42b-c331-709b6435f737@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] vhost: check malloc return value when allocating guest pages 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: Mon, 22 May 2017 06:42:30 -0000 On Thu, May 18, 2017 at 10:14:26AM +0200, Maxime Coquelin wrote: > > > On 05/11/2017 05:25 PM, Jens Freimann wrote: > >When we try to allocate guest pages we need to check the return value of > >malloc(). Print an error message and return when it fails. > > > >Signed-off-by: Jens Freimann > >--- > > lib/librte_vhost/vhost_user.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > >diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > >index 5c8058b..437e41f 100644 > >--- a/lib/librte_vhost/vhost_user.c > >+++ b/lib/librte_vhost/vhost_user.c > >@@ -515,6 +515,13 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg) > > dev->max_guest_pages = 8; > > dev->guest_pages = malloc(dev->max_guest_pages * > > sizeof(struct guest_page)); > >+ if (dev->guest_pages == NULL) { > >+ RTE_LOG(ERR, VHOST_CONFIG, > >+ "(%d) failed to allocate memory " > >+ "for dev->guest_pages\n", > >+ dev->vid); > >+ return -1; > >+ } > > } > > dev->mem = rte_zmalloc("vhost-mem-table", sizeof(struct rte_vhost_memory) + > > > > Reviewed-by: Maxime Coquelin Applied to dpdk-next-virtio. Thanks. --yliu