From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1172C37B1 for ; Wed, 19 Apr 2017 17:02:26 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2017 08:02:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,221,1488873600"; d="scan'208";a="1121378265" Received: from silpixa00381631.ir.intel.com (HELO silpixa00381631.ger.corp.intel.com) ([10.237.222.122]) by orsmga001.jf.intel.com with ESMTP; 19 Apr 2017 08:02:24 -0700 From: Pablo de Lara To: roy.fan.zhang@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 19 Apr 2017 16:02:15 +0100 Message-Id: <1492614135-27777-1-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] crypto/scheduler: fix uninitialized capability structure 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: Wed, 19 Apr 2017 15:02:27 -0000 Capability information is updated as slaves are attached, but if this information is requested via rte_cryptodev_info_get() when no slaves have been attached, the structure would not be initialized, leading to a potential segmentation fault. Therefore, the structure should be initialized with no capabilities at device creation. Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations") Signed-off-by: Pablo de Lara --- drivers/crypto/scheduler/scheduler_pmd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c index f2a1d2a..4ac31bb 100644 --- a/drivers/crypto/scheduler/scheduler_pmd.c +++ b/drivers/crypto/scheduler/scheduler_pmd.c @@ -202,6 +202,20 @@ cryptodev_scheduler_create(const char *name, sched_ctx->nb_init_slaves++; } + /* + * Initialize capabilities structure as an empty structure, + * in case device information is requested when no slaves are attached + */ + sched_ctx->capabilities = rte_zmalloc_socket(NULL, + sizeof(struct rte_cryptodev_capabilities), + 0, SOCKET_ID_ANY); + + if (!sched_ctx->capabilities) { + RTE_LOG(ERR, PMD, "Not enough memory for capability " + "information\n"); + return -ENOMEM; + } + return 0; } -- 2.7.4