[{"id":17394,"web_url":"https://patchwork.libcamera.org/comment/17394/","msgid":"<20210603051734.GC156622@pyrite.rasen.tech>","date":"2021-06-03T05:17:34","subject":"Re: [libcamera-devel] [PATCH v4] gstreamer: Add error checking in\n\tgst_libcamera_src_task_enter()","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Vedant,\n\nOn Wed, Jun 02, 2021 at 07:41:38PM +0530, Vedant Paranjape wrote:\n> The return value from generateConfiguration() was not checked. Only assert\n> was added as a guard which checked if the size of generated camera config was\n\ns/size of/size of the/\n\n> equal to size of roles passed to it.\n> \n> If the roles variable has an invalid/unsupported role, it will return\n> a nullptr and then trying to access a member on a nullptr for size comparison\n> will result in a segmentation fault. So, if the function returns a nullptr,\n> it will simply push an error message on GstBus and gracefully exit.\n\ns/it will simply/simply/\n\nWhat you did in the patch should be stated imperatively.\n\n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\nI'll wait for Nicolas to re-review this patch and then I'll push with\nthose changes applied.\n\n> ---\n>  src/gstreamer/gstlibcamerasrc.cpp | 11 +++++++----\n>  1 file changed, 7 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\n> index 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> -- \n> 2.25.1\n>","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 20D3FC3206\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Jun 2021 05:17:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 960E368923;\n\tThu,  3 Jun 2021 07:17:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 88F5E602A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Jun 2021 07:17:43 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 64DB04A5;\n\tThu,  3 Jun 2021 07:17:41 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gHL3auZq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1622697463;\n\tbh=ZYObgvc4s38PTzZ/4e2aDFwBteapcFA084OdBTzRVuc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gHL3auZq3qJ32skxxGTlefRuSO68mGmJ4kOs0avX4wfIBCsfOenUqpL6y6Tpx0E1h\n\t7RYawk/5g73Ub3Mh4JGttw77f/K5udwq8S8UwlXI0w55BvpqrWbEMVvQNf1VQsTkqE\n\tnrvRktAG3ZOjMVcWI11q2WrHMjBcEJNPoQu0s7FA=","Date":"Thu, 3 Jun 2021 14:17:34 +0900","From":"paul.elder@ideasonboard.com","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<20210603051734.GC156622@pyrite.rasen.tech>","References":"<20210602141138.582472-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210602141138.582472-1-vedantparanjape160201@gmail.com>","Subject":"Re: [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":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17405,"web_url":"https://patchwork.libcamera.org/comment/17405/","msgid":"<5835ed82ab46261a044f86fd3ac0a987d06647b0.camel@ndufresne.ca>","date":"2021-06-04T14:39:28","subject":"Re: [libcamera-devel] [PATCH v4] gstreamer: Add error checking in\n\tgst_libcamera_src_task_enter()","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le jeudi 03 juin 2021 à 14:17 +0900, paul.elder@ideasonboard.com a écrit :\n> Hi Vedant,\n> \n> On Wed, Jun 02, 2021 at 07:41:38PM +0530, Vedant Paranjape wrote:\n> > The return value from generateConfiguration() was not checked. Only assert\n> > was added as a guard which checked if the size of generated camera config was\n> \n> s/size of/size of the/\n> \n> > equal to size of roles passed to it.\n> > \n> > If the roles variable has an invalid/unsupported role, it will return\n> > a nullptr and then trying to access a member on a nullptr for size comparison\n> > will result in a segmentation fault. So, if the function returns a nullptr,\n> > it will simply push an error message on GstBus and gracefully exit.\n> \n> s/it will simply/simply/\n> \n> What you did in the patch should be stated imperatively.\n> \n> > Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> \n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> I'll wait for Nicolas to re-review this patch and then I'll push with\n> those changes applied.\n\nWas lost from V3,\n\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\n> \n> > ---\n> >  src/gstreamer/gstlibcamerasrc.cpp | 11 +++++++----\n> >  1 file changed, 7 insertions(+), 4 deletions(-)\n> > \n> > diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\n> > index 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> > -- \n> > 2.25.1\n> >","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 ECE0DC3208\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  4 Jun 2021 14:39:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 58DF068926;\n\tFri,  4 Jun 2021 16:39:33 +0200 (CEST)","from mail-qk1-x730.google.com (mail-qk1-x730.google.com\n\t[IPv6:2607:f8b0:4864:20::730])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D41A268925\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  4 Jun 2021 16:39:31 +0200 (CEST)","by mail-qk1-x730.google.com with SMTP id k11so7891405qkk.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 04 Jun 2021 07:39:31 -0700 (PDT)","from nicolas-tpx395.localdomain (173-246-12-168.qc.cable.ebox.net.\n\t[173.246.12.168]) by smtp.gmail.com with ESMTPSA id\n\tg6sm3959001qkm.120.2021.06.04.07.39.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 04 Jun 2021 07:39:29 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=ndufresne-ca.20150623.gappssmtp.com\n\theader.i=@ndufresne-ca.20150623.gappssmtp.com\n\theader.b=\"Yclpq0LD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=message-id:subject:from:to:cc:date:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=+p2xVsfExGJkhTKdv5jiJ1N9CivrRzqy1f/UcNUpdeI=;\n\tb=Yclpq0LD7WE4QTnaQoULXiibZ7X0IZYbg74kvKGbAxsNadlpk44SpTzGbMtZrZHngw\n\t11LIDsPgvdGE/4ekjDUO4fp6xb3qKNClSD3hMvkFxSmtZkJ+Rm6UoZmlRSTyBDKx2+L5\n\t7MVVldMlr5EN1yZR/RWILGt8+pXdlg7wsoXs4o/AaJwD3VR7qO1u8c8AbhLX4+RLVCk4\n\tytohZ4XX5BwBox2hgyJGkRZeTPIAlP+oeMmVfUTMed42mSRlPx/wG41e/IfHcx0x1no6\n\ta0ptg/krFw3bESDTM+Qr5jru1NjqLxfHxPKs0a5Fzd9XDJVIz6dUN1WE6kp+oAe9z9Vw\n\tbIjQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=+p2xVsfExGJkhTKdv5jiJ1N9CivrRzqy1f/UcNUpdeI=;\n\tb=LVVsUnkGeaboC9INP3r+emjmR6/i34j2QXaA/h04dOk9PEMoVwLUosLth/Pg56s+Nl\n\tm2aR4pX43HrBfrm+188wmIXlK8k5Dubqm629VL/QeBRrlq+i5GLeME81vzCv6rYJP2Hh\n\tgXNkiESt+YauHKW/x6Q2gMtNrUR4hIbjdxxSes5nnFe4EGmIWPluqWLi5uVUV8jSe2St\n\t4WoTY5I2dK5h2fNVuc9RwhXMXueQkViEtd7juI5yj9yBt9sLrw95PZB1vvf2Lm54CGhV\n\ttGk7WVfvaANYPkMhH8WHRhv+HQ1mqH7sTsmI7A4ZPYmHnzF60bOcRqWJG+xiyb7FwMeE\n\tgg0A==","X-Gm-Message-State":"AOAM532ubPUsewBSXsXhSKUuKYKgALdERxtmni1jzQHxLPWppEfyeKbw\n\t26GgLMRZ3RtAJUgpOGlrUL62Lw==","X-Google-Smtp-Source":"ABdhPJwy5v09sVFmHDhX8bbHHXyiwTybKcV6sYnW+Ff8zc/FV7x7GVX/mvwRTQUVjeHi0vDbhv6f6w==","X-Received":"by 2002:a37:46c8:: with SMTP id\n\tt191mr4507311qka.311.1622817570467; \n\tFri, 04 Jun 2021 07:39:30 -0700 (PDT)","Message-ID":"<5835ed82ab46261a044f86fd3ac0a987d06647b0.camel@ndufresne.ca>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"paul.elder@ideasonboard.com, Vedant Paranjape\n\t<vedantparanjape160201@gmail.com>","Date":"Fri, 04 Jun 2021 10:39:28 -0400","In-Reply-To":"<20210603051734.GC156622@pyrite.rasen.tech>","References":"<20210602141138.582472-1-vedantparanjape160201@gmail.com>\n\t<20210603051734.GC156622@pyrite.rasen.tech>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.40.1 (3.40.1-1.fc34) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [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":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]