From patchwork Tue Jun 1 19:24:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 12481 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3F101C3205 for ; Tue, 1 Jun 2021 19:24:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 73DDA68922; Tue, 1 Jun 2021 21:24:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QqSh1imW"; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE5E26891F for ; Tue, 1 Jun 2021 21:24:27 +0200 (CEST) Received: by mail-pj1-x102a.google.com with SMTP id d5-20020a17090ab305b02901675357c371so1709095pjr.1 for ; Tue, 01 Jun 2021 12:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MdhfF88Fb90w3ObISPFTLCeyM6NQNh1XntsiXhbQZ0Y=; b=QqSh1imWNJyy8a25xyrSvfk8bCZhPU6HEUhrKk1zfvtyfegoeNqwtqCOMyY3h5EIDT mE3mFp/CkvUie1pGjkgwa4dj2XdVv6U7Wh5KJ62i4AutJSmvcN0tbOfJKD+kDr/TULnA kDTuHf+Mf8FAAZCVVhwW5k20PqbWNImU6diiy8+l6kg/P34hUHy4JpynkRLy404oJl5J 9VdLzFardweqP9C9nxjeMVpTxtK7VpcvuhGFBbyHFAGaNkoGui1AJawEhWmXqme6jR1n KAuKqd6opg59wQOWzSxcCcJz9C2pm5/SQEz0De9y/MdjXOGTjmsSLpwd3VKrDACP79md bmtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MdhfF88Fb90w3ObISPFTLCeyM6NQNh1XntsiXhbQZ0Y=; b=j8zr768mtiFkDcu0cmc4sTG2W4nQshatbP5W8IW2/yfxpwzVfyRWlWkJ3ZoTB5any/ 1szIoMOlyPybCkEKy6hUyxfNB8hYmltfCBGWXkn9jCp+4ASTMRMmw4jZF2EslwSHCYub y0L3Bh36pSLtnqtNi3tyExldpV0V3C1TvSiEo0EUW3J7G9KtGikGdcfICSGSg0sQM2t+ HdDgbfutabop6N80+8h02cPyz0YjqPYVgaSFZOP0IJU26hcdoPR666J2fTN3H1JEqKLx yf/Yw0h84Qyog34VnEvA6SRRrtdIjWFz/u8fziJ66lhpZieZuAZRzOPWCEUiTrt5IqZs SSMA== X-Gm-Message-State: AOAM531XwtSeknt7vwtvULhbQ9uPzs4Q5fMOW7jZIJXnlZCI0rt/1iFN eto/VBGSJCFv55JT6TWpMeNk79Hah9Yb8Q== X-Google-Smtp-Source: ABdhPJyTgYfYvpPQUpnb7DgbGiuIFNJRVK4CvYMC5RCarn2Ya+efavFooyDjFibaxCrqO7lNZhuFSg== X-Received: by 2002:a17:902:be0a:b029:104:4f7c:8140 with SMTP id r10-20020a170902be0ab02901044f7c8140mr13295554pls.70.1622575465626; Tue, 01 Jun 2021 12:24:25 -0700 (PDT) Received: from localhost.localdomain ([1.186.76.76]) by smtp.googlemail.com with ESMTPSA id v20sm7518066pgc.42.2021.06.01.12.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 12:24:25 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Jun 2021 00:54:05 +0530 Message-Id: <20210601192405.143591-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] gstreamer: Add error checking in gst_libcamera_src_task_enter() 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: , Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Error checking the output from generateConfiguration() was missing in the code. Only assert was added as a guard which checked if the size of generated camera config was equal to size of roles passed to it. If the roles argument has a invalid member, it will return a nullptr and then trying to access a member on a nullptr for size comparison will result in a segmentation fault. So, if the function returns a nullptr, it will simply put a error on GstBus and gracefully exit. Signed-off-by: Vedant Paranjape --- src/gstreamer/gstlibcamerasrc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 8b6057df..910c0f83 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -375,9 +375,9 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, /* Generate the stream configurations, there should be one per pad. */ state->config_ = state->cam_->generateConfiguration(roles); - if (state->config_ == nullptr) { + if (state->config_ == nullptr && state->config_->size() == state->srcpads_.size()) { GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS, - ("Failed to generate camera configuration from roles"), + ("Failed to generate camera configuration from"), ("Camera::generateConfiguration() returned nullptr")); gst_task_stop(task); return;