From patchwork Mon Apr 27 03:17:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3563 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E04EB61212 for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d3MHoxbY"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7FAF672C for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957456; bh=L/Id3vhye5F7dVlO7V/6uEru7Nw+QzFKHtGenNJ4v/A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d3MHoxbYWCUUdYbcebOsvdg2vxWiLIRRpOtgu9oUyF93/ZQcX5sAfSbFWWo9gs0Vm M4/F4FmXFaUQAktjwcVK0z9utbR+ULE9SYtr5BLtiYnThiSu8vhBlygf3P416XJom1 gdpWnM6AR/aBlHUE+SNol03QNXWpBmjwRCJVv5qo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:13 +0300 Message-Id: <20200427031713.14013-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 11/11] ipa: vimc: Validate configuration file in init() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2020 03:17:39 -0000 Make sure we can open the configuration file passed to the init() function, and return an error otherwise. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/vimc/vimc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index e6bda8ec58b0..f29bc504d8c8 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -19,6 +19,7 @@ #include +#include "file.h" #include "log.h" namespace libcamera { @@ -65,7 +66,15 @@ int IPAVimc::init(const IPASettings &settings) { trace(IPAOperationInit); - LOG(IPAVimc, Debug) << "initializing vimc IPA!"; + LOG(IPAVimc, Debug) + << "initializing vimc IPA with configuration file " + << settings.configurationFile; + + File conf(settings.configurationFile); + if (!conf.open(File::ReadOnly)) { + LOG(IPAVimc, Error) << "Failed to open configuration file"; + return -EINVAL; + } return 0; }