From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91703A00C2 for ; Wed, 17 Mar 2021 09:21:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABA02242B9B; Wed, 17 Mar 2021 09:21:31 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 7AC94242B93; Wed, 17 Mar 2021 09:21:29 +0100 (CET) IronPort-SDR: dYvpKh/DDMiupn1BOBX6fomCRR5IcDiCcIcLvpfvLjbBAx/E2qjaF6rWpQ0tDoaoWEoCqFWxzt TzO5t0IrreJQ== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="274463932" X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="274463932" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 01:21:27 -0700 IronPort-SDR: ilj1iQUHIGcCAQwtR5OeDlTsRP15GQnGmsPVIknl286ocoejWJb3rrhVe5ZiGqqkpmrBWQdMv3 ZMBxVkYb9dOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="602144377" Received: from unknown (HELO sh_lab5_1.sh.intel.com) ([10.238.175.190]) by fmsmga006.fm.intel.com with ESMTP; 17 Mar 2021 01:21:26 -0700 From: Wei Huang To: dev@dpdk.org, rosen.xu@intel.com, qi.z.zhang@intel.com Cc: stable@dpdk.org, tianfei.zhang@intel.com, Wei Huang Date: Wed, 17 Mar 2021 04:21:34 -0400 Message-Id: <1615969296-17021-3-git-send-email-wei.huang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615969296-17021-1-git-send-email-wei.huang@intel.com> References: <1615969296-17021-1-git-send-email-wei.huang@intel.com> Subject: [dpdk-stable] [PATCH v1 2/4] raw/ifpga/base: check return value of lseek X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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: 7a4f3993f269 ("raw/ifpga: add FPGA RSU APIs") Signed-off-by: Wei Huang --- drivers/raw/ifpga/base/ifpga_fme_rsu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga/base/ifpga_fme_rsu.c b/drivers/raw/ifpga/base/ifpga_fme_rsu.c index d32f1eccb1..a4cb2f54ba 100644 --- a/drivers/raw/ifpga/base/ifpga_fme_rsu.c +++ b/drivers/raw/ifpga/base/ifpga_fme_rsu.c @@ -130,7 +130,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", -- 2.29.2