net/softnic: fix memory leak in connection init

Message ID 20210709060056.957949-1-dapengx.yu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series net/softnic: fix memory leak in connection init |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing warning Testing issues
ci/iol-testing success Testing PASS

Commit Message

Yu, DapengX July 9, 2021, 6 a.m. UTC
  From: Dapeng Yu <dapengx.yu@intel.com>

In function softnic_conn_init(), a block of memory is allocated as
connection buffer, but it is never freed in softnic_conn_free(),
which cause memory leak.

This patch fixes it.

Fixes: 7709a63bf178 ("net/softnic: add connection agent")
Cc: stable@dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
---
 drivers/net/softnic/conn.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Andrew Rybchenko July 13, 2021, 9:37 a.m. UTC | #1
On 7/9/21 9:00 AM, dapengx.yu@intel.com wrote:
> From: Dapeng Yu <dapengx.yu@intel.com>
> 
> In function softnic_conn_init(), a block of memory is allocated as
> connection buffer, but it is never freed in softnic_conn_free(),
> which cause memory leak.
> 
> This patch fixes it.
> 
> Fixes: 7709a63bf178 ("net/softnic: add connection agent")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
> ---
>  drivers/net/softnic/conn.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/softnic/conn.c b/drivers/net/softnic/conn.c
> index 8b66580887..a9548beac7 100644
> --- a/drivers/net/softnic/conn.c
> +++ b/drivers/net/softnic/conn.c
> @@ -146,6 +146,7 @@ softnic_conn_free(struct softnic_conn *conn)
>  	free(conn->msg_in);
>  	free(conn->prompt);
>  	free(conn->welcome);
> +	free(conn->buf);
>  	free(conn);
>  }
>  
> 

Fixed order to free in reverse order vs fields in the structure
and allocation.

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Applied, thanks.
  

Patch

diff --git a/drivers/net/softnic/conn.c b/drivers/net/softnic/conn.c
index 8b66580887..a9548beac7 100644
--- a/drivers/net/softnic/conn.c
+++ b/drivers/net/softnic/conn.c
@@ -146,6 +146,7 @@  softnic_conn_free(struct softnic_conn *conn)
 	free(conn->msg_in);
 	free(conn->prompt);
 	free(conn->welcome);
+	free(conn->buf);
 	free(conn);
 }