examples/fips_validation: fix resource leak on failure

Message ID 20201028155327.104488-1-ciara.power@intel.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series examples/fips_validation: fix resource leak on failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Power, Ciara Oct. 28, 2020, 3:53 p.m. UTC
  The dst variable went out of scope on failure in the get_writeback_data
function. This is now freed before returning -1.

Coverity issue: 363453
Fixes: 952e10cdad5e ("examples/fips_validation: support scatter gather list")
Cc: roy.fan.zhang@intel.com

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 examples/fips_validation/main.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

David Marchand Oct. 30, 2020, 1:08 p.m. UTC | #1
On Wed, Oct 28, 2020 at 4:53 PM Ciara Power <ciara.power@intel.com> wrote:
>
> The dst variable went out of scope on failure in the get_writeback_data
> function. This is now freed before returning -1.
>
> Coverity issue: 363453
> Fixes: 952e10cdad5e ("examples/fips_validation: support scatter gather list")
> Cc: roy.fan.zhang@intel.com
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
>  examples/fips_validation/main.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
> index 07532c9562..be38eb29b6 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1128,6 +1128,7 @@ get_writeback_data(struct fips_val *val)
>
>         if (data_len) {
>                 RTE_LOG(ERR, USER1, "Error -1: write back data\n");
> +               free(dst);

Hum should we instead free the pointer to the allocated buffer, i.e.
wb_data, rather than dst that got potentially incremented?
  

Patch

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 07532c9562..be38eb29b6 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1128,6 +1128,7 @@  get_writeback_data(struct fips_val *val)
 
 	if (data_len) {
 		RTE_LOG(ERR, USER1, "Error -1: write back data\n");
+		free(dst);
 		return -1;
 	}