From patchwork Thu Jul 18 04:27:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1715 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E01160C00 for ; Thu, 18 Jul 2019 06:27:59 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D84AE31C; Thu, 18 Jul 2019 06:27:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1563424079; bh=VgpNqd0uoDVg/dMV53qz4/lCObiaydJrZg1Ub8LHIbQ=; h=From:To:Cc:Subject:Date:From; b=W0ZYW3ilRcUL8RHctImvd4RAOmfFoYnU06799tawZnwL2lf112VjctXq7+tsKgz9k rfkygKs4aIRkJD/De7BoBnxx9y9Xk0OUvb4pTqc5JnTS/Uutjgk4tFuFHptZqCfHY3 V9AywrGmITqZsRYGGaAkSa/igFJXrWXc0yS2VTjs= From: Kieran Bingham To: LibCamera Devel Date: Thu, 18 Jul 2019 05:27:54 +0100 Message-Id: <20190718042754.26535-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: camera: Fail to configure on mis-configured streams X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2019 04:27:59 -0000 Uses of LOG(x, Fatal) and ASSERT() should be capable of continuing without crashing. Camera::configure() validates that each StreamConfiguration has a Stream* and reports a Fatal error otherwise. The code then goes on to dereference the Stream pointer which will be a nullptr in the event of the Fatal error being triggered. In release builds, ASSERTS are compiled out, and LOG(x, Fatal) should attempt to continue or report the error up the call-stack. Make Camera::configure() return an error in the event that the Stream* is not valid. This will cause the configure operation to fail and the application will be notified just as other errors in the Camera::configure() operation do. Signed-off-by: Kieran Bingham --- src/libcamera/camera.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 76c737cb9381..7ad9e0e48686 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -672,9 +672,11 @@ int Camera::configure(CameraConfiguration *config) activeStreams_.clear(); for (const StreamConfiguration &cfg : *config) { Stream *stream = cfg.stream(); - if (!stream) + if (!stream) { LOG(Camera, Fatal) << "Pipeline handler failed to update stream configuration"; + return -EINVAL; + } stream->configuration_ = cfg; activeStreams_.insert(stream);