Skip to content

Commit 7c7812a

Browse files
coverity fix: uninit -Wmismatched-dealloc
Signed-off-by: Utkarsh Gupta <utkarsh.gupta@nxp.com>
1 parent 026bef0 commit 7c7812a

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

src/imx_signer.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -378,21 +378,22 @@ static int create_csf_file_v1(image_block_t *blocks, int idx, char *ofname)
378378

379379
if (0 > (snprintf(csf_filename, sizeof(csf_filename), "csf_image%d.txt", idx))) {
380380
fprintf(stderr, "ERROR: Cannot populate CSF file name.\n");
381-
goto err;
381+
return -E_FAILURE;
382382
}
383383

384384
/* Create CSF file with CSF parameters */
385385
FILE *fp_csf_file = fopen(csf_filename, "w");
386386
if (NULL == fp_csf_file ) {
387387
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", csf_filename, strerror(errno));
388-
goto err;
388+
return -E_FAILURE;
389389
}
390390

391391
/* Open CSF config file */
392392
FILE *fp_cfg = fopen(g_cfgfilename, "r");
393393
if (NULL == fp_cfg) {
394394
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", g_cfgfilename, strerror(errno));
395-
goto err;
395+
FCLOSE(fp_csf_file);
396+
return -E_FAILURE;
396397
}
397398

398399
/* Populate CSF file with appropriate parameters */
@@ -602,11 +603,6 @@ static int create_csf_file_v1(image_block_t *blocks, int idx, char *ofname)
602603
FCLOSE(fp_csf_file);
603604
FCLOSE(fp_cfg);
604605
return E_OK;
605-
606-
err:
607-
FCLOSE(fp_csf_file);
608-
FCLOSE(fp_cfg);
609-
return -E_FAILURE;
610606
}
611607

612608

@@ -632,14 +628,15 @@ static int create_csf_file_v3(char *csf_filename, char *ifname, csf_params_t *cs
632628
FILE *fp_csf_file = fopen(csf_filename, "w");
633629
if (NULL == fp_csf_file ) {
634630
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", csf_filename, strerror(errno));
635-
goto err;
631+
return -E_FAILURE;
636632
}
637633

638634
/* Open CSF config file */
639635
FILE *fp_cfg = fopen(g_cfgfilename, "r");
640636
if (NULL == fp_cfg) {
641-
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", g_cfgfilename, strerror(errno));
642-
goto err;
637+
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", g_cfgfilename, strerror(errno));
638+
FCLOSE(fp_csf_file);
639+
return -E_FAILURE;
643640
}
644641

645642
/* Populate CSF file with appropriate parameters */
@@ -717,11 +714,6 @@ static int create_csf_file_v3(char *csf_filename, char *ifname, csf_params_t *cs
717714
FCLOSE(fp_csf_file);
718715
FCLOSE(fp_cfg);
719716
return E_OK;
720-
721-
err:
722-
FCLOSE(fp_csf_file);
723-
FCLOSE(fp_cfg);
724-
return -E_FAILURE;
725717
}
726718

727719
/*
@@ -742,14 +734,15 @@ static int create_spsdk_yaml_file(char *yaml_filename)
742734
FILE *fp_yaml_file = fopen(yaml_filename, "w");
743735
if (NULL == fp_yaml_file ) {
744736
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", yaml_filename, strerror(errno));
745-
goto err;
737+
return -E_FAILURE;
746738
}
747739

748740
/* Open nxpimage config file */
749741
FILE *fp_cfg = fopen(g_cfgfilename, "r");
750742
if (NULL == fp_cfg) {
751-
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", g_cfgfilename, strerror(errno));
752-
goto err;
743+
fprintf(stderr, "ERROR: Couldn't open file: %s; %s\n", g_cfgfilename, strerror(errno));
744+
FCLOSE(fp_yaml_file);
745+
return -E_FAILURE;
753746
}
754747

755748
/* Populate YAML config file with appropriate parameters */
@@ -851,11 +844,6 @@ static int create_spsdk_yaml_file(char *yaml_filename)
851844
FCLOSE(fp_yaml_file);
852845
FCLOSE(fp_cfg);
853846
return E_OK;
854-
855-
err:
856-
FCLOSE(fp_yaml_file);
857-
FCLOSE(fp_cfg);
858-
return -E_FAILURE;
859847
}
860848

861849
/*

0 commit comments

Comments
 (0)