From 097d8acb68c7d7dbfd7800c7f69eaf171ce9da4b Mon Sep 17 00:00:00 2001 From: Changsheng Wu <wuchangsheng2@huawei.com> Date: Sat, 18 Dec 2021 16:49:16 +0800 Subject: [PATCH] 0009 --- lib/eal/linux/eal.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index f269e67fae..2555043155 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -524,22 +524,29 @@ rte_config_init(void) return 0; } -static void +static int rte_sec_config_init(const int sec_idx) { int mem_cfg_fd = -1; int mmap_flags = PROT_READ | PROT_WRITE; + int ret = -1; struct rte_config *rte_cfg = rte_eal_sec_get_configuration(sec_idx); struct internal_config *internal_conf = rte_eal_sec_get_internal_config(sec_idx); rte_cfg->process_type = internal_conf->process_type; - __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, + ret = __rte_eal_config_attach(mmap_flags, &mem_cfg_fd, rte_eal_sec_get_runtime_dir(sec_idx), internal_conf, rte_cfg); + if (ret < 0) { + RTE_LOG(ERR, EAL, "Cannot attach shared memory\n"); + return -1; + } + close(mem_cfg_fd); + return 0; } static int @@ -1561,7 +1568,11 @@ rte_eal_sec_attach(int argc, char **argv) return -1; } - rte_sec_config_init(sec_idx); + ret = rte_sec_config_init(sec_idx); + if (ret < 0) { + RTE_LOG(ERR, EAL, "Cannot init sec config\n"); + return -1; + } ret = rte_eal_sec_memory_init(sec_idx); if (ret < 0) { -- 2.27.0