Commit b51c4938 authored by Federico Vaga's avatar Federico Vaga

sw:lib: bugfix resource release of error

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 09daf8d0
......@@ -596,7 +596,7 @@ int trtl_cpu_load_application_file(struct trtl_dev *trtl,
unsigned int index,
const char *path)
{
int i, len;
int i, len, err = 0;
void *code;
FILE *f;
......@@ -608,28 +608,30 @@ int trtl_cpu_load_application_file(struct trtl_dev *trtl,
len = ftell(f);
rewind(f);
if (!len)
return 0;
goto out;
code = malloc(len);
if (!code)
return -1;
if (!code) {
err = -1;
goto out_close;
}
/* Get the code from file */
i = fread(code, 1, len, f);
fclose(f);
if (!i || i != len) {
/*TODO: maybe optimize me with a loop */
free(code);
return -1;
err = -1;
goto out_free;
}
i = trtl_cpu_load_application_raw(trtl, index, code, len, 0);
if (i != len)
return -1;
err = -1;
out_free:
free(code);
return 0;
out_close:
fclose(f);
out:
return err;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment