From patchwork Fri May 15 12:42:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3799 Return-Path: Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C8E560E13 for ; Fri, 15 May 2020 14:42:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="kRhlQZhY"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=ypx0l5S1eElZCfSsU6JNux9dqR9MqHq//0HJwRPZiXQ=; b=kRhlQZhYSMduwhgznKTjuIUNOOjSXmksmAbzA0U4rWxCTeYlijM7Fp1w14lsmSl/e/EE qkjVWnWQ7YX2RhVgqJvgMbKZ7+6JPZUSRZSJtiqK69jOzLf4cOMh7L4xmTFbCnFmFDlpDV GDc1CXccT2aZyzH+rEk4dAjqEh/u+Se2A= Received: by filter0073p3las1.sendgrid.net with SMTP id filter0073p3las1-3640-5EBE8E4E-78 2020-05-15 12:42:54.653166209 +0000 UTC m=+2558432.897400713 Received: from mail.uajain.com (unknown) by ismtpd0004p1maa1.sendgrid.net (SG) with ESMTP id oFd7B2YPR3uLTzPSq6__pw for ; Fri, 15 May 2020 12:42:54.314 +0000 (UTC) From: Umang Jain Date: Fri, 15 May 2020 12:42:54 +0000 (UTC) Message-Id: <20200515124245.18040-5-email@uajain.com> In-Reply-To: <20200515124245.18040-1-email@uajain.com> References: <20200515124245.18040-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcHcG1g99dnq0SJ9KzJgHEPjOpQm5nI00z0W5yXxIY20eIcETDJ2Ss6SYI8o0hWQQY0W/VcDAzx52NVFzR2xL95/5ThFhdtAZmVqw1oZmMRBaCp5qCiFYCcFYR7J7oKqlAkDomGRBcm4EvbvC9G8Drm9e2636Ve23+nxTExsPgeL4xCUETGEIwyrlDMg4iHAUJ To: libcamera-devel Subject: [libcamera-devel] [PATCH v2 4/4] libcamera: camera: Return -EINVAL if any stream is null while configure() 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: Fri, 15 May 2020 12:42:58 -0000 Fail and return the Camera::configure() operation if any of the stream turns out to be a nullptr even after the PipelineHandler handler seems to have configured the config successfully. This prevents a null-dereference below in the loop. Pointed out by Coverity DefectId=279069 Signed-off-by: Umang Jain Reported-by: Coverity CID=279069 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/camera.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 8c3bb2c..9d2607b 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -777,9 +777,12 @@ int Camera::configure(CameraConfiguration *config) p_->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"; + p_->activeStreams_.clear(); + return -EINVAL; + } stream->configuration_ = cfg; p_->activeStreams_.insert(stream);