It looks good.

> -----Original Message-----
> From: Chengwen Feng <fengcheng...@huawei.com>
> Sent: Monday, February 6, 2023 18:53
> To: tho...@monjalon.net; ferruh.yi...@amd.com; Xu, Rosen
> <rosen...@intel.com>; Zhang, Tianfei <tianfei.zh...@intel.com>; Huang,
> Wei <wei.hu...@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH 2/2] raw/ifpga/base: fix mmap retcode check fail
> 
> 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: sta...@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengcheng...@huawei.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 1117c3e160..6d48d227d6 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.17.1

Reply via email to