Skip to contentSkip to conversation

examples/fips_validation: fix resource leak on failure

PATCH Superseded Ciara Power 2 participants 4 messages Oct 28, 2020 – Oct 31, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/fips_validation: fix resource leak on failure

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")
---
 examples/fips_validation/main.c | 1 +
 1 file changed, 1 insertion(+)
examples/fips_validation/main.c +1 -0
index 07532c9562..be38eb29b6 100644
@@ -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;
 	}
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 18 lines · Ciara Power

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")
---
 examples/fips_validation/main.c | 1 +
 1 file changed, 1 insertion(+)
examples/fips_validation/main.c +0 -0
index 07532c9562..be38eb29b6 100644

examples/fips_validation/main.c get_writeback_data(struct fips_val *val) · line 1131

Quoted 4 lines
examples/fips_validation/main.c +1 -0
@@ -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?

Signature · 1 line
David Marchand
#2 lore raw

PATCH v2 1/1 examples/fips_validation: fix resource leak on failure

In reply to Ciara Power

The wb_data 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")

---
v2: Fixed incorrect pointer used in free.

---
 examples/fips_validation/main.c | 1 +
 1 file changed, 1 insertion(+)
examples/fips_validation/main.c +1 -0
index 07532c9562..b37eb41c0d 100644
@@ -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(wb_data);
 		return -1;
 	}
 
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1 Applied
#3 lore raw
Quoted 8 lines · Ciara Power

The wb_data 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")

Applied, thanks.

Signature · 1 line
David Marchand