From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2017 03:30:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,441,1496127600"; d="scan'208";a="117629150" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga002.jf.intel.com with ESMTP; 31 Jul 2017 03:30:29 -0700 From: Pablo de Lara To: declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Mon, 31 Jul 2017 03:30:50 +0100 Message-Id: <20170731023050.28956-1-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 Subject: [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 10:30:32 -0000 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