summaryrefslogtreecommitdiff
path: root/lib/ipmi_hpmfwupg.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipmi_hpmfwupg.c')
-rw-r--r--lib/ipmi_hpmfwupg.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c
index c589009..12671ce 100644
--- a/lib/ipmi_hpmfwupg.c
+++ b/lib/ipmi_hpmfwupg.c
@@ -1385,28 +1385,26 @@ int
HpmfwupgGetBufferFromFile(char *imageFilename,
struct HpmfwupgUpgradeCtx *pFwupgCtx)
{
- int rc = HPMFWUPG_SUCCESS;
+ int rc = HPMFWUPG_ERROR;
int ret = 0;
FILE *pImageFile = fopen(imageFilename, "rb");
if (!pImageFile) {
lprintf(LOG_ERR, "Cannot open image file '%s'",
imageFilename);
- return HPMFWUPG_ERROR;
+ goto ret_no_close;
}
/* Get the raw data in file */
ret = fseek(pImageFile, 0, SEEK_END);
if (ret != 0) {
lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
imageFilename);
- fclose(pImageFile);
- return HPMFWUPG_ERROR;
+ goto ret_close;
}
pFwupgCtx->imageSize = ftell(pImageFile);
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
if (!pFwupgCtx->pImageData) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
- fclose(pImageFile);
- return HPMFWUPG_ERROR;
+ goto ret_close;
}
rewind(pImageFile);
ret = fread(pFwupgCtx->pImageData,
@@ -1418,9 +1416,14 @@ HpmfwupgGetBufferFromFile(char *imageFilename,
"Failed to read file %s size %d",
imageFilename,
pFwupgCtx->imageSize);
- rc = HPMFWUPG_ERROR;
+ goto ret_close;
}
+
+ rc = HPMFWUPG_SUCCESS;
+
+ret_close:
fclose(pImageFile);
+ret_no_close:
return rc;
}