{"id":12488,"url":"https://patchwork.libcamera.org/api/1.1/patches/12488/?format=json","web_url":"https://patchwork.libcamera.org/patch/12488/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210602141138.582472-1-vedantparanjape160201@gmail.com>","date":"2021-06-02T14:11:38","name":"[libcamera-devel,v4] gstreamer: Add error checking in gst_libcamera_src_task_enter()","commit_ref":"1e5cee701781276fb03f18e704a5a6ea8f24eff8","pull_url":null,"state":"accepted","archived":false,"hash":"0086865ab6b355456d14fbae562a7de215c028b6","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/1.1/people/85/?format=json","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12488/mbox/","series":[{"id":2101,"url":"https://patchwork.libcamera.org/api/1.1/series/2101/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2101","date":"2021-06-02T14:11:38","name":"[libcamera-devel,v4] gstreamer: Add error checking in gst_libcamera_src_task_enter()","version":4,"mbox":"https://patchwork.libcamera.org/series/2101/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12488/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12488/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6D7F2C3206\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Jun 2021 14:12:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B737D6050E;\n\tWed,  2 Jun 2021 16:12:11 +0200 (CEST)","from mail-pf1-x429.google.com (mail-pf1-x429.google.com\n\t[IPv6:2607:f8b0:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA87B602A4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Jun 2021 16:12:10 +0200 (CEST)","by mail-pf1-x429.google.com with SMTP id t28so2265989pfg.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 02 Jun 2021 07:12:10 -0700 (PDT)","from localhost.localdomain ([1.186.77.76])\n\tby smtp.googlemail.com with ESMTPSA id\n\th13sm11124122pfv.213.2021.06.02.07.12.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 02 Jun 2021 07:12:08 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"EtVP0m5G\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=SbK0I8xpvPDcvtfHcRdhUVxXQi27eU32jcL2FhTducs=;\n\tb=EtVP0m5Ghl0HGOFXGxJWjapO/wndchTc6tINvtcImN/+WUmR5D1rcvKRdGEFcDlrPd\n\t1/klyWbJO77YXK46WLjTSW/tOJqYRvnJs/2jPXZSNLDUkr29gpKoP7dK585FS+zdOlc5\n\t6hEc4v0jS/3PqREoJD+vEy1rMYZ7N9N+l2NJSm7Eu0lVg+AlFQsTIgDQxywIEWpXiYU0\n\txlIn7sbHhpNkCHyDjlC1ulk5CcJ7yD6yWmyylhJonXVgppfV2wve8LUWAKrsVXYpJ1C/\n\tgIimF3adBUwQs05Mre7nIdXXORjDcPdPpVg3KlJTM5woR4c0DNFyIVRucJBxmYNlkxtN\n\t5Ffw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=SbK0I8xpvPDcvtfHcRdhUVxXQi27eU32jcL2FhTducs=;\n\tb=qsnlso7IWAMD4q1po2hPQXv+n0cZNBgG6oWqTJw7SWhC/ZWlmT7WeUXaqmMkTFBTBG\n\tSfHG3sw1Wuh9xJben+K8Kodi/bbtvKI/AOFIuX/Wt/0wHIcjYHhYq546QrW+jilH3Pgl\n\tWyR9oDrjqgGvdTeTMxPkCkJGt7P4z1YfN0DCh14W4ChAMZzoCHxPXP8HHAC1dMBiqoEb\n\tA2OKvdQ1UdzlQAaUdbGqdGiyqlTEUsmvLJIR8gAyUhqGQ+xu/peRI3yZZGGg1CaqFLvA\n\tnLEkwAev8iUmIHiHqF+KH/DY1uK+NbV+QDWcqAzesrBQamIRh9MhPeOJfPPFzBra31PD\n\tGrnQ==","X-Gm-Message-State":"AOAM5334dX9axiJ8GGhsUtl6LBFW+weowEfSE2ecubTRzUu8L8Fg2VMS\n\t4geHtNwW6+giV0cI42FBfqV93khuHJVyk3JJ","X-Google-Smtp-Source":"ABdhPJzez3I6T9ou7ZowqSBKoAYBk7B2MqoaFInqvuuNJqp0h2EwmSztAYLS+ydX/pqQ/xw6ER+QNA==","X-Received":"by 2002:a05:6a00:2b5:b029:2ea:a29:a117 with SMTP id\n\tq21-20020a056a0002b5b02902ea0a29a117mr6966628pfs.35.1622643128617; \n\tWed, 02 Jun 2021 07:12:08 -0700 (PDT)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  2 Jun 2021 19:41:38 +0530","Message-Id":"<20210602141138.582472-1-vedantparanjape160201@gmail.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4] gstreamer: Add error checking in\n\tgst_libcamera_src_task_enter()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The return value from generateConfiguration() was not checked. Only assert\nwas added as a guard which checked if the size of generated camera config was\nequal to size of roles passed to it.\n\nIf the roles variable has an invalid/unsupported role, it will return\na nullptr and then trying to access a member on a nullptr for size comparison\nwill result in a segmentation fault. So, if the function returns a nullptr,\nit will simply push an error message on GstBus and gracefully exit.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n---\n src/gstreamer/gstlibcamerasrc.cpp | 11 +++++++----\n 1 file changed, 7 insertions(+), 4 deletions(-)","diff":"diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 87246b40..ccc61590 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -375,10 +375,13 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,\n \n \t/* Generate the stream configurations, there should be one per pad. */\n \tstate->config_ = state->cam_->generateConfiguration(roles);\n-\t/*\n-\t * \\todo Check if camera may increase or decrease the number of streams\n-\t * regardless of the number of roles.\n-\t */\n+\tif (state->config_ == nullptr) {\n+\t\tGST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,\n+\t\t\t\t  (\"Failed to generate camera configuration from roles\"),\n+\t\t\t\t  (\"Camera::generateConfiguration() returned nullptr\"));\n+\t\tgst_task_stop(task);\n+\t\treturn;\n+\t}\n \tg_assert(state->config_->size() == state->srcpads_.size());\n \n \tfor (gsize i = 0; i < state->srcpads_.size(); i++) {\n","prefixes":["libcamera-devel","v4"]}