From patchwork Wed Apr 15 05:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3465 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 747B260401 for ; Wed, 15 Apr 2020 07:45:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="Mj/sIodP"; 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=lrbXJDnJcq4VZgT3K6ez6zxjNNaIGEwmsRuz1QvxbIA=; b=Mj/sIodPu443dqkhVsTPg82eG5deXLSMb+cMoBkfsLpjeGdwi2JptxRk8QnO3LgFEwC2 3rglKkXBlN2ovqbmyIgxxNDpFy1biIqsVb0Jy98A3kRbvPornaDFz/lKFxLcvrpBUMEYEY X8wq09j4ZtQhwbLhPVf15v3AKFkfTXZrs= Received: by filterdrecv-p3iad2-8ddf98858-rpdh9 with SMTP id filterdrecv-p3iad2-8ddf98858-rpdh9-19-5E969F6F-7B 2020-04-15 05:45:19.993893761 +0000 UTC m=+1744665.744333156 Received: from mail.uajain.com (unknown) by ismtpd0003p1hnd1.sendgrid.net (SG) with ESMTP id A3swGOmzQziNlN_GX-F5eA Wed, 15 Apr 2020 05:45:19.659 +0000 (UTC) From: Umang Jain Date: Wed, 15 Apr 2020 05:45:20 +0000 (UTC) Message-Id: <20200415054503.13108-2-email@uajain.com> In-Reply-To: <20200415054503.13108-1-email@uajain.com> References: <20200415054503.13108-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcREc2X1LpIgLW8oEasGbegwNe7IMCDmAC73/5ndg0KnN8FeRmppZxrI4nW6/opvAP7npBHmfip7NzsBQ9kBknVuSlOji4fyN3tF9F4ujBj/4a63dtsieeSGvAB68WDRoZK5JzCNCSpGSBjj7DPi/doS7udR93H6C5c3LRrPPc9XhaWooOGDijoPvOPYXwceeZCi+6vffp26KxMzf7PtSMfg== To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH v2 1/2] 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: Wed, 15 Apr 2020 05:45:21 -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 --- 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);