From: Wei Huang Date: Wed, 17 Mar 2021 08:21:34 +0000 (-0400) Subject: raw/ifpga/base: check lseek failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=226ecdea99ce2ad4e1554b50fc7c2c4ca069191f;p=dpdk.git raw/ifpga/base: check lseek failure 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 Acked-by: Tianfei Zhang Acked-by: Rosen Xu --- diff --git a/drivers/raw/ifpga/base/ifpga_fme_rsu.c b/drivers/raw/ifpga/base/ifpga_fme_rsu.c index 28198abd78..b5e018d3e7 100644 --- a/drivers/raw/ifpga/base/ifpga_fme_rsu.c +++ b/drivers/raw/ifpga/base/ifpga_fme_rsu.c @@ -128,7 +128,12 @@ static int write_flash_image(struct ifpga_sec_mgr *smgr, const char *image, 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",