Commit 3b2ed51e authored by Ye Li's avatar Ye Li

MLK-20239-2 imx8m: check lseek return value

Fix coverity issue CID 4338240, CID 4338242:
Unchecked return value from library (CHECKED_RETURN)

check_return: Calling lseek(fd, fit_offset + fit_size, 0) without checking return
value. This library function may fail and return an error code
Signed-off-by: default avatarYe Li <ye.li@nxp.com>
parent 27c55d8e
...@@ -259,10 +259,16 @@ struct fdt_header { ...@@ -259,10 +259,16 @@ struct fdt_header {
static void fill_zero(int ifd, int size, int offset) static void fill_zero(int ifd, int size, int offset)
{ {
int fill_size; int fill_size;
int ret;
uint8_t zeros[4096]; uint8_t zeros[4096];
memset(zeros, 0, sizeof(zeros)); memset(zeros, 0, sizeof(zeros));
lseek(ifd, offset, SEEK_SET); ret = lseek(ifd, offset, SEEK_SET);
if (ret < 0) {
fprintf(stderr, "%s: lseek error %s\n",
__func__, strerror(errno));
exit(EXIT_FAILURE);
}
while (size) { while (size) {
...@@ -852,8 +858,14 @@ int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep, uint32_t *fit_load ...@@ -852,8 +858,14 @@ int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep, uint32_t *fit_load
uint32_t fit_size, load_addr; uint32_t fit_size, load_addr;
int align_len = 64 - 1; /* 64 is cacheline size */ int align_len = 64 - 1; /* 64 is cacheline size */
int ret;
lseek(fd, fit_offset, SEEK_SET); ret = lseek(fd, fit_offset, SEEK_SET);
if (ret < 0) {
fprintf(stderr, "%s: lseek error %s\n",
__func__, strerror(errno));
exit(EXIT_FAILURE);
}
if (read(fd, (char *)&image_header, sizeof(uimage_header_t)) != sizeof(uimage_header_t)) { if (read(fd, (char *)&image_header, sizeof(uimage_header_t)) != sizeof(uimage_header_t)) {
fprintf (stderr, "generate_ivt_for_fit read failed: %s\n", fprintf (stderr, "generate_ivt_for_fit read failed: %s\n",
...@@ -873,7 +885,12 @@ int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep, uint32_t *fit_load ...@@ -873,7 +885,12 @@ int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep, uint32_t *fit_load
fit_size = ALIGN(fit_size, ALIGN_SIZE); fit_size = ALIGN(fit_size, ALIGN_SIZE);
lseek(fd, fit_offset + fit_size, SEEK_SET); ret = lseek(fd, fit_offset + fit_size, SEEK_SET);
if (ret < 0) {
fprintf(stderr, "%s: lseek error %s\n",
__func__, strerror(errno));
exit(EXIT_FAILURE);
}
/* ep is the u-boot entry. SPL loads the FIT before the u-boot address. 0x2000 is for CSF_SIZE */ /* ep is the u-boot entry. SPL loads the FIT before the u-boot address. 0x2000 is for CSF_SIZE */
load_addr = (ep - (fit_size + CSF_SIZE) - 512 - load_addr = (ep - (fit_size + CSF_SIZE) - 512 -
......
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