examples/pipeline: fix file close

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

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-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-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:35 a.m. UTC
  Coverity issue: 380860
Fixes: 9043f66a ("examples/pipeline: add command for code generation")

Fix file close at pipeline code generation.

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 | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Thomas Monjalon Oct. 5, 2022, 12:34 p.m. UTC | #1
27/09/2022 06:35, Harshad Narayane:
> Coverity issue: 380860
> Fixes: 9043f66a ("examples/pipeline: add command for code generation")
> 
> Fix file close at pipeline code generation.
> 
> 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>
> ---
> --- a/examples/pipeline/cli.c
> +++ b/examples/pipeline/cli.c
> @@ -545,6 +545,7 @@ cmd_pipeline_codegen(char **tokens,
>  	code_file = fopen(tokens[3], "w");
>  	if (!code_file) {
>  		snprintf(out, out_size, "Cannot open file %s.\n", tokens[3]);
> +		fclose(spec_file);
>  		return;
>  	}


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

Patch

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 8013541c4b..1158e51e89 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -545,6 +545,7 @@  cmd_pipeline_codegen(char **tokens,
 	code_file = fopen(tokens[3], "w");
 	if (!code_file) {
 		snprintf(out, out_size, "Cannot open file %s.\n", tokens[3]);
+		fclose(spec_file);
 		return;
 	}