From 388e551dc3d558f82804c144059ac2eb6df7d27c Mon Sep 17 00:00:00 2001 From: John Zhao Date: Fri, 18 Sep 2020 11:54:05 -0700 Subject: 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 Change-Id: I86af322dc78845b8b312b6815135336c2c56b4dd Reviewed-on: https://review.coreboot.org/c/coreboot/+/45531 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak --- src/drivers/intel/mipi_camera/camera.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3