[v4,1/2] lib/cmdline: release cl when cmdline exit

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Peng, ZhihongX Oct. 13, 2021, 1:52 a.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: stable@dpdk.org

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

Comments

Olivier Matz Oct. 15, 2021, 12:58 p.m. UTC | #1
On Wed, Oct 13, 2021 at 01:52:22AM +0000, zhihongx.peng@intel.com wrote:
> 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: stable@dpdk.org

As said by Dmitry, we should not backport this fix to avoid breaking
external apps.

> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>

I suggest to merge the 2 patches in one, because the second is mandatory
when the first one is applied.

Thanks Zhihong, and thanks Dmitry for the previous review.
  
Peng, ZhihongX Oct. 18, 2021, 5:16 a.m. UTC | #2
> -----Original Message-----
> From: Olivier Matz <olivier.matz@6wind.com>
> Sent: Friday, October 15, 2021 8:58 PM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: dmitry.kozliuk@gmail.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit
> 
> On Wed, Oct 13, 2021 at 01:52:22AM +0000, zhihongx.peng@intel.com wrote:
> > 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: stable@dpdk.org
> 
> As said by Dmitry, we should not backport this fix to avoid breaking external
> apps.

The v5 version will be fixed.
> > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> 
> I suggest to merge the 2 patches in one, because the second is mandatory
> when the first one is applied.

The v5 version will be fixed
> Thanks Zhihong, and thanks Dmitry for the previous review.
  

Patch

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index f643a61f44..2f59077709 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -226,6 +226,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);
 }