examples/pipeline: fix memory free

Message ID 20220927043732.366980-1-harshad.suresh.narayane@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series examples/pipeline: fix memory free |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Suresh Narayane, Harshad Sept. 27, 2022, 4:37 a.m. UTC
  Coverity issue: 380863
Coverity issue: 380866
Fixes: 6bc14d9f ("examples/pipeline: add command for shared library build")

Fix memory resource free for buffer allocation failure at pipeline
library build.

Signed-off-by: Harshad Narayane <harshad.suresh.narayane@intel.com>
Signed-off-by: Kamalakannan R <kamalakannan.r@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/pipeline/cli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 5, 2022, 12:30 p.m. UTC | #1
27/09/2022 06:37, Harshad Narayane:
> Coverity issue: 380863
> Coverity issue: 380866
> Fixes: 6bc14d9f ("examples/pipeline: add command for shared library build")
> 
> Fix memory resource free for buffer allocation failure at pipeline
> library build.
> 
> Signed-off-by: Harshad Narayane <harshad.suresh.narayane@intel.com>
> Signed-off-by: Kamalakannan R <kamalakannan.r@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Reordered lines in the commit log and applied, thanks.
Note: this is not fixing "free", it was missing,
but it is fixing a leak.
  

Patch

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 1158e51e89..e1e7aaddc1 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -642,7 +642,7 @@  cmd_pipeline_libbuild(char **tokens,
 	buffer = malloc(MAX_LINE_SIZE);
 	if (!buffer) {
 		snprintf(out, out_size, MSG_OUT_OF_MEMORY);
-		return;
+		goto free;
 	}
 
 	snprintf(buffer,