eal: unmap undesired address upon config reattach failure

Message ID 1566110854-2669-1-git-send-email-arnon@qwilt.com
State Superseded
Headers show
Series
  • eal: unmap undesired address upon config reattach failure
Related show

Checks

Context Check Description
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing fail Performance Testing issues
ci/iol-Compile-Testing success Compile Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Arnon Warshavsky Aug. 18, 2019, 6:47 a.m.
Have rte_eal_config_reattach clean up the mapped address
which is a valid address but not the one intended.

Coverity issue: 343439
Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/linux/eal/eal.c | 1 +
 1 file changed, 1 insertion(+)

Comments

David Marchand Aug. 19, 2019, 8:27 a.m. | #1
On Sun, Aug 18, 2019 at 8:47 AM Arnon Warshavsky <arnon@qwilt.com> wrote:
>
> Have rte_eal_config_reattach clean up the mapped address
> which is a valid address but not the one intended.
>
> Coverity issue: 343439

Fixes: 4e8854ae89fa ("eal: do not panic on shared memory init")
Since the issue was hidden before that.

> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>

FreeBSD has the same issue since:
b149a7064261 ("eal/freebsd: add config reattach in secondary process")


> ---
>  lib/librte_eal/linux/eal/eal.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
> index 946222c..fac69b9 100644
> --- a/lib/librte_eal/linux/eal/eal.c
> +++ b/lib/librte_eal/linux/eal/eal.c
> @@ -438,6 +438,7 @@ enum rte_iova_mode
>                         RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]"
>                                 " - please use '--base-virtaddr' option\n",
>                                 rte_mem_cfg_addr, mem_config);
> +                       munmap(mem_config, sizeof(struct rte_mem_config));
>                         return -1;
>                 }
>                 RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
> --
> 1.8.3.1
>

Thanks.

Reviewed-by: David Marchand <david.marchand@redhat.com>

Patch

diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 946222c..fac69b9 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -438,6 +438,7 @@  enum rte_iova_mode
 			RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]"
 				" - please use '--base-virtaddr' option\n",
 				rte_mem_cfg_addr, mem_config);
+			munmap(mem_config, sizeof(struct rte_mem_config));
 			return -1;
 		}
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",