aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/intel
diff options
context:
space:
mode:
authorJohn Zhao <john.zhao@intel.com>2020-09-18 11:54:05 -0700
committerPatrick Georgi <pgeorgi@google.com>2020-09-21 08:12:25 +0000
commit388e551dc3d558f82804c144059ac2eb6df7d27c (patch)
treef48b9896d6cb5826656d12b55a35ba87ee02da4b /src/drivers/intel
parent342d0a8365bc0a61936bfd1deba69dc0d4f68d05 (diff)
drivers/intel/mipi_camera: Avoid resource leak
Coverity detects variable dsd going out of scope leaks the storage it points to. Move dsd resource allocation after sanity check for config->nvm_compact to avoid leak. Found-by: Coverity CID 1432727 TEST=Built and boot up to kernel on Volteer. Signed-off-by: John Zhao <john.zhao@intel.com> Change-Id: I86af322dc78845b8b312b6815135336c2c56b4dd Reviewed-on: https://review.coreboot.org/c/coreboot/+/45531 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/drivers/intel')
-rw-r--r--src/drivers/intel/mipi_camera/camera.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c
index fed0ff6cba..d4cf33d9fb 100644
--- a/src/drivers/intel/mipi_camera/camera.c
+++ b/src/drivers/intel/mipi_camera/camera.c
@@ -452,11 +452,13 @@ static void camera_fill_sensor(const struct device *dev)
static void camera_fill_nvm(const struct device *dev)
{
struct drivers_intel_mipi_camera_config *config = dev->chip_info;
- struct acpi_dp *dsd = acpi_dp_new_table("_DSD");
+ struct acpi_dp *dsd;
if (!config->nvm_compat)
return;
+ dsd = acpi_dp_new_table("_DSD");
+
/* It might be possible to default size or width based on type. */
if (!config->disable_nvm_defaults && !config->nvm_pagesize)
config->nvm_pagesize = 1;