From: Pablo de Lara Date: Wed, 19 Apr 2017 15:02:15 +0000 (+0100) Subject: crypto/scheduler: fix uninitialized capabilities X-Git-Tag: spdx-start~3456 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c570f262e8ce3cf0c186b435a9dfa80ce7536802;p=dpdk.git crypto/scheduler: fix uninitialized capabilities 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") Cc: stable@dpdk.org Signed-off-by: Pablo de Lara Acked-by: Fan Zhang --- diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c index dfa21c228f..0b63c20ba0 100644 --- a/drivers/crypto/scheduler/scheduler_pmd.c +++ b/drivers/crypto/scheduler/scheduler_pmd.c @@ -171,6 +171,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; }