In max10_staging_area_init(), variable "start" from fdt_get_reg() may
be invalid, it should be checked before assigning to member variable
"staging_area_base" of structure "intel_max10_device".
Coverity issue: 367480, 367482
Fixes:
a05bd1b40bde ("raw/ifpga: add FPGA RSU APIs")
Cc: stable@dpdk.org
Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
continue;
ret = fdt_get_reg(fdt_root, offset, 0, &start, &size);
- if (!ret && (size <= MAX_STAGING_AREA_SIZE)) {
- dev->staging_area_base = start;
- dev->staging_area_size = size;
- }
+ if (ret)
+ return ret;
+
+ if ((start & 0x3) || (start > MAX_STAGING_AREA_BASE) ||
+ (size > MAX_STAGING_AREA_SIZE))
+ return -EINVAL;
+
+ dev->staging_area_base = start;
+ dev->staging_area_size = size;
+
return ret;
}
#define SBUS_VERSION GENMASK(31, 16)
#define DFT_MAX_SIZE 0x7e0000
+#define MAX_STAGING_AREA_BASE 0xffffffff
#define MAX_STAGING_AREA_SIZE 0x3800000
int max10_reg_read(struct intel_max10_device *dev,