[v5] lib/cmdline: release cl when cmdline exit

Message ID 20211018135850.1348365-1-zhihongx.peng@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v5] lib/cmdline: release cl when cmdline exit |

Checks

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

Commit Message

Peng, ZhihongX Oct. 18, 2021, 1:58 p.m. UTC
  From: Zhihong Peng <zhihongx.peng@intel.com>

Malloc cl in the cmdline_stdin_new function, so release in the
cmdline_stdin_exit function is logical, so that cl will not be
released alone.

Fixes: af75078fece3 ("first public release")
Cc: intel.com

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 app/test/test.c                        | 1 -
 app/test/test_cmdline_lib.c            | 1 -
 doc/guides/rel_notes/release_21_11.rst | 3 +++
 lib/cmdline/cmdline_socket.c           | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)
  

Comments

Dmitry Kozlyuk Oct. 18, 2021, 2:29 p.m. UTC | #1
2021-10-18 21:58 (UTC+0800), zhihongx.peng@intel.com:
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be
> released alone.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: intel.com
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>

Reviewed-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
  
Olivier Matz Oct. 20, 2021, 7:03 a.m. UTC | #2
On Mon, Oct 18, 2021 at 05:29:35PM +0300, Dmitry Kozlyuk wrote:
> 2021-10-18 21:58 (UTC+0800), zhihongx.peng@intel.com:
> > From: Zhihong Peng <zhihongx.peng@intel.com>
> > 
> > Malloc cl in the cmdline_stdin_new function, so release in the
> > cmdline_stdin_exit function is logical, so that cl will not be
> > released alone.
> > 
> > Fixes: af75078fece3 ("first public release")
> > Cc: intel.com
> > 
> > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Reviewed-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
  
Peng, ZhihongX Oct. 20, 2021, 9:22 a.m. UTC | #3
> -----Original Message-----
> From: Peng, ZhihongX <zhihongx.peng@intel.com>
> Sent: Monday, October 18, 2021 9:59 PM
> To: olivier.matz@6wind.com; dmitry.kozliuk@gmail.com
> Cc: dev@dpdk.org; Peng, ZhihongX <zhihongx.peng@intel.com>
> Subject: [PATCH v5] lib/cmdline: release cl when cmdline exit
> 
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be released alone.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: intel.com
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
>  app/test/test.c                        | 1 -
>  app/test/test_cmdline_lib.c            | 1 -
>  doc/guides/rel_notes/release_21_11.rst | 3 +++
>  lib/cmdline/cmdline_socket.c           | 1 +
>  4 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test/test.c b/app/test/test.c index 173d202e47..5194131026
> 100644
> --- a/app/test/test.c
> +++ b/app/test/test.c
> @@ -233,7 +233,6 @@ main(int argc, char **argv)
> 
>  		cmdline_interact(cl);
>  		cmdline_stdin_exit(cl);
> -		cmdline_free(cl);
>  	}
>  #endif
>  	ret = 0;
> diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c index
> d5a09b4541..6bcfa6511e 100644
> --- a/app/test/test_cmdline_lib.c
> +++ b/app/test/test_cmdline_lib.c
> @@ -174,7 +174,6 @@ test_cmdline_socket_fns(void)
>  	/* void functions */
>  	cmdline_stdin_exit(NULL);
> 
> -	cmdline_free(cl);
>  	return 0;
>  error:
>  	printf("Error: function accepted null parameter!\n"); diff --git
> a/doc/guides/rel_notes/release_21_11.rst
> b/doc/guides/rel_notes/release_21_11.rst
> index d5435a64aa..6aa98d1e34 100644
> --- a/doc/guides/rel_notes/release_21_11.rst
> +++ b/doc/guides/rel_notes/release_21_11.rst
> @@ -237,6 +237,9 @@ API Changes
>    the crypto/security operation. This field will be used to communicate
>    events such as soft expiry with IPsec in lookaside mode.
> 
> +* cmdline: ``cmdline_stdin_exit()`` now frees the ``cmdline`` structure.
> +  Calls to ``cmdline_free()`` after it need to be deleted from applications.
> +
> 
>  ABI Changes
>  -----------
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index 998e8ade25..ebd5343754 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
>  		return;
> 
>  	terminal_restore(cl);
> +	cmdline_free(cl);
>  }
> --
> 2.25.1

Tested-by: Zhihong Peng <zhihongx.peng@intel.com>
  
Thomas Monjalon Oct. 22, 2021, 9:33 p.m. UTC | #4
20/10/2021 09:03, Olivier Matz:
> On Mon, Oct 18, 2021 at 05:29:35PM +0300, Dmitry Kozlyuk wrote:
> > 2021-10-18 21:58 (UTC+0800), zhihongx.peng@intel.com:
> > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > > 
> > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > cmdline_stdin_exit function is logical, so that cl will not be
> > > released alone.
> > > 
> > > Fixes: af75078fece3 ("first public release")
> > > Cc: intel.com
> > > 
> > > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > 
> > Reviewed-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks.
  

Patch

diff --git a/app/test/test.c b/app/test/test.c
index 173d202e47..5194131026 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -233,7 +233,6 @@  main(int argc, char **argv)
 
 		cmdline_interact(cl);
 		cmdline_stdin_exit(cl);
-		cmdline_free(cl);
 	}
 #endif
 	ret = 0;
diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c
index d5a09b4541..6bcfa6511e 100644
--- a/app/test/test_cmdline_lib.c
+++ b/app/test/test_cmdline_lib.c
@@ -174,7 +174,6 @@  test_cmdline_socket_fns(void)
 	/* void functions */
 	cmdline_stdin_exit(NULL);
 
-	cmdline_free(cl);
 	return 0;
 error:
 	printf("Error: function accepted null parameter!\n");
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index d5435a64aa..6aa98d1e34 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -237,6 +237,9 @@  API Changes
   the crypto/security operation. This field will be used to communicate
   events such as soft expiry with IPsec in lookaside mode.
 
+* cmdline: ``cmdline_stdin_exit()`` now frees the ``cmdline`` structure.
+  Calls to ``cmdline_free()`` after it need to be deleted from applications.
+
 
 ABI Changes
 -----------
diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
index 998e8ade25..ebd5343754 100644
--- a/lib/cmdline/cmdline_socket.c
+++ b/lib/cmdline/cmdline_socket.c
@@ -53,4 +53,5 @@  cmdline_stdin_exit(struct cmdline *cl)
 		return;
 
 	terminal_restore(cl);
+	cmdline_free(cl);
 }