From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo de Lara Subject: [PATCH] cryptodev: fix NULL pointer dereference Date: Mon, 31 Jul 2017 03:30:50 +0100 Message-ID: <20170731023050.28956-1-pablo.de.lara.guarch@intel.com> Cc: dev@dpdk.org, Pablo de Lara To: declan.doherty@intel.com Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id EF6DB99A6 for ; Mon, 31 Jul 2017 12:30:31 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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; -- 2.9.4