In write_flash_image(), calling function "lseek" without checking
return value has risk. Negative return value should be handled as
an error condition.
Coverity issue: 367478
Fixes: a05bd1b40bde ("raw/ifpga: add FPGA RSU APIs")
Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
do {
to_transfer = (length > IFPGA_RSU_DATA_BLK_SIZE) ?
IFPGA_RSU_DATA_BLK_SIZE : length;
- lseek(fd, offset, SEEK_SET);
+ if (lseek(fd, offset, SEEK_SET) < 0) {
+ dev_err(smgr, "Failed to seek in \'%s\' [e:%s]\n",
+ image, strerror(errno));
+ ret = -EIO;
+ goto end;
+ }
read_size = read(fd, buf, to_transfer);
if (read_size < 0) {
dev_err(smgr, "Failed to read from \'%s\' [e:%s]\n",