[v5] lib/cmdline: release cl when cmdline exit
Checks
Commit Message
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
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>
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>
> -----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>
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.
@@ -233,7 +233,6 @@ main(int argc, char **argv)
cmdline_interact(cl);
cmdline_stdin_exit(cl);
- cmdline_free(cl);
}
#endif
ret = 0;
@@ -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");
@@ -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
-----------
@@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
return;
terminal_restore(cl);
+ cmdline_free(cl);
}