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 CF5347CAB for ; Mon, 31 Jul 2017 14:33:02 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2017 05:33:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,442,1496127600"; d="scan'208";a="293708029" Received: from smonroyx-mobl.ger.corp.intel.com (HELO [10.237.221.5]) ([10.237.221.5]) by fmsmga004.fm.intel.com with ESMTP; 31 Jul 2017 05:32:59 -0700 To: Pablo de Lara , declan.doherty@intel.com References: <20170731023050.28956-1-pablo.de.lara.guarch@intel.com> Cc: dev@dpdk.org From: Sergio Gonzalez Monroy Message-ID: Date: Mon, 31 Jul 2017 13:32:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <20170731023050.28956-1-pablo.de.lara.guarch@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] cryptodev: fix 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: Mon, 31 Jul 2017 12:33:03 -0000 On 31/07/2017 03:30, Pablo de Lara wrote: > When registering a crypto driver, if memory allocation > fails, application should exit and do not allow > a NULL pointer dereference. > > Coverity issue: 158645 > > Fixes: 7a364faef185 ("cryptodev: remove crypto device type enumeration") > > Signed-off-by: Pablo de Lara > --- > lib/librte_cryptodev/rte_cryptodev.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c > index 327d7e8..4492b0d 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -1404,6 +1404,12 @@ rte_cryptodev_allocate_driver(const struct rte_driver *drv) > struct cryptodev_driver *driver; > > driver = malloc(sizeof(*driver)); > + > + if (driver == NULL) > + rte_exit(EXIT_FAILURE, > + "Could not allocate memory for crypto driver %u\n", > + nb_drivers); > + > driver->driver = drv; > driver->id = nb_drivers; > Acked-by: Sergio Gonzalez Monroy