dpdk/0278-raw-ifpga-base-fix-init-with-multi-process.patch
chenjiji09 28f243f30b fix empty devargs parsing
Sync some patchs from upstreaming and modifies are as
follow:
1. The rte_kvargs_process() was used to parse KV pairs, it
also supports to parse 'only keys' type. And the callback
function parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with
'only keys'.
2. The MAP_FAILED should be used to determine whether the
mapping is successful but not NULL. This patch fix it.

(cherry picked from commit dfaed15bf9253e6b71dda7639806c0b265164a9e)
2023-04-29 07:48:24 +08:00

45 lines
1.5 KiB
Diff

From 08ad2bc6e7fd4bc11b25011dbae48268828d372f Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Mon, 6 Feb 2023 10:53:11 +0000
Subject: raw/ifpga/base: fix init with multi-process
[ upstream commit e6a2804b77c5fbfd97d0fe05ec7f959a0404a380 ]
The MAP_FAILED should be used to determine whether the mapping is
successful.
Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
---
drivers/raw/ifpga/base/opae_hw_api.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/raw/ifpga/base/opae_hw_api.c b/drivers/raw/ifpga/base/opae_hw_api.c
index 11c9887c7f..45efe70473 100644
--- a/drivers/raw/ifpga/base/opae_hw_api.c
+++ b/drivers/raw/ifpga/base/opae_hw_api.c
@@ -380,7 +380,7 @@ static pthread_mutex_t *opae_adapter_mutex_open(struct opae_adapter *adapter)
PROT_READ | PROT_WRITE, MAP_SHARED,
shm_id, 0);
adapter->lock = (pthread_mutex_t *)ptr;
- if (ptr) {
+ if (ptr != MAP_FAILED) {
dev_info(NULL,
"shared memory %s address is %p\n",
shm_name, ptr);
@@ -499,7 +499,7 @@ static void *opae_adapter_shm_alloc(struct opae_adapter *adapter)
adapter->shm.size = size;
adapter->shm.ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_SHARED, shm_id, 0);
- if (adapter->shm.ptr) {
+ if (adapter->shm.ptr != MAP_FAILED) {
dev_info(NULL,
"shared memory %s address is %p\n",
shm_name, adapter->shm.ptr);
--
2.23.0