app/proc-info: add rte_eal_cleanup() to avoid memory leak

Message ID 20220818113742.138791-1-fidaullah.noonari@emumba.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series app/proc-info: add rte_eal_cleanup() to avoid memory leak |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Fidaullah Noonari Aug. 18, 2022, 11:37 a.m. UTC
when app is launched with -m proc-info exit without
rte_eal_cleanup() causing memory leakage. This commit resolves the
memory leakage issue and closes app properly.

Bugzilla id: 898

Signed-off-by: Fidaullah Noonari <fidaullah.noonari@emumba.com>
---
 app/proc-info/main.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Stephen Hemminger Aug. 18, 2022, 2:53 p.m. UTC | #1
On Thu, 18 Aug 2022 16:37:42 +0500
Fidaullah Noonari <fidaullah.noonari@emumba.com> wrote:

> when app is launched with -m proc-info exit without
> rte_eal_cleanup() causing memory leakage. This commit resolves the
> memory leakage issue and closes app properly.
> 
> Bugzilla id: 898
> 
> Signed-off-by: Fidaullah Noonari <fidaullah.noonari@emumba.com>
> ---
>  app/proc-info/main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/app/proc-info/main.c b/app/proc-info/main.c
> index 1bfba5f60d..44a946045e 100644
> --- a/app/proc-info/main.c
> +++ b/app/proc-info/main.c
> @@ -1523,6 +1523,9 @@ main(int argc, char **argv)
>  
>  	if (mem_info) {
>  		meminfo_display();
> +		ret = rte_eal_cleanup();
> +		if (ret != 0)
> +			printf("Error from rte_eal_cleanup(), %d\n", ret);

A goto would avoid duplicating code:

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 1bfba5f60d10..9cfcce31ab9a 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1523,7 +1523,7 @@ main(int argc, char **argv)
 
        if (mem_info) {
                meminfo_display();
-               return 0;
+               goto cleanup;
        }
 
        nb_ports = rte_eth_dev_count_avail();
@@ -1593,6 +1593,7 @@ main(int argc, char **argv)
        RTE_ETH_FOREACH_DEV(i)
                rte_eth_dev_close(i);
 
+cleanup:
        ret = rte_eal_cleanup();
        if (ret)
                printf("Error from rte_eal_cleanup(), %d\n", ret);
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 1bfba5f60d..44a946045e 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1523,6 +1523,9 @@  main(int argc, char **argv)
 
 	if (mem_info) {
 		meminfo_display();
+		ret = rte_eal_cleanup();
+		if (ret != 0)
+			printf("Error from rte_eal_cleanup(), %d\n", ret);
 		return 0;
 	}