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 8E77AA0579; Thu, 8 Apr 2021 10:57:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D8A0714118C; Thu, 8 Apr 2021 10:57:42 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 9ED6F141184; Thu, 8 Apr 2021 10:57:40 +0200 (CEST) IronPort-SDR: LC6zvSr64zqf66MPEFKSF/NcPRxqeX35GXqdXOXYUbc3cwx/WD/daOqyg+7T0uPWrwB5bnr3cC Rl4yqIeNRztg== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="173575038" X-IronPort-AV: E=Sophos;i="5.82,205,1613462400"; d="scan'208";a="173575038" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2021 01:57:40 -0700 IronPort-SDR: SdB/6zol2vTl4VP14MjwPclTa9Xr60QGgFrRBMYwPMCoybLxs0AdO8VlWOrkkBanbSWEUlzKna 2cqkN5gtTmEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,205,1613462400"; d="scan'208";a="458739858" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.238.175.107]) by orsmga001.jf.intel.com with ESMTP; 08 Apr 2021 01:57:38 -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, ferruh.yigit@intel.com, Wei Huang Date: Thu, 8 Apr 2021 04:51:51 -0400 Message-Id: <20210408085151.54996-2-wei.huang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210408085151.54996-1-wei.huang@intel.com> References: <20210408085151.54996-1-wei.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In max10_staging_area_init(), variable "size" from fdt_get_reg() may be invalid, it should be checked before assigning to member variable "staging_area_size" of structure "intel_max10_device". Coverity issue: 367480, 367482 Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device driver") Signed-off-by: Wei Huang --- v2: check size before assigning to staging_area_size --- drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- drivers/raw/ifpga/base/opae_intel_max10.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c index 443e248fb3..c223fafa03 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.c +++ b/drivers/raw/ifpga/base/opae_intel_max10.c @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct intel_max10_device *dev) continue; ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); - if (!ret) { + if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { dev->staging_area_base = start; dev->staging_area_size = size; } diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h b/drivers/raw/ifpga/base/opae_intel_max10.h index 670683f017..e7142d6f0d 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.h +++ b/drivers/raw/ifpga/base/opae_intel_max10.h @@ -182,6 +182,7 @@ struct opae_retimer_status { #define SBUS_VERSION GENMASK(31, 16) #define DFT_MAX_SIZE 0x7e0000 +#define MAX_STAGING_AREA_SIZE 0x3800000 int max10_reg_read(struct intel_max10_device *dev, unsigned int reg, unsigned int *val); -- 2.29.2