[{"id":4877,"web_url":"https://patchwork.libcamera.org/comment/4877/","msgid":"<20200520151533.ojh22kvaclrleywl@uno.localdomain>","date":"2020-05-20T15:15:33","subject":"Re: [libcamera-devel] [PATCH] libcamera: raspberry: Fix segfault in\n\t~RPiCameraData()","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"On Wed, May 20, 2020 at 05:10:19PM +0200, Jacopo Mondi wrote:\n> The RPiCameraData class destructor tries to stop its ipa_ instance\n> without making sure it has been initialized.\n>\n> If the RPiCameraData gets destroyed before its ipa_ member is\n> initialized, in example if the sensor initialization fails during the\n> match() function. A nullptr dereference segfault is triggered preventing\n> a graceful library teardown.\n>\n> Fix this by checking for ipa_ to be initialized before stopping it.\n>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++-\n>  src/libcamera/property_ids.yaml                    | 1 -\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 07ca9f5d7f53..e16a9c7f10d3 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -304,7 +304,8 @@ public:\n>  \t\t}\n>\n>  \t\t/* Stop the IPA proxy thread. */\n> -\t\tipa_->stop();\n> +\t\tif (ipa_)\n> +\t\t\tipa_->stop();\n>  \t}\n>\n>  \tvoid frameStarted(uint32_t sequence);\n> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n> index 2ae178a73d52..da4d0bbf329c 100644\n> --- a/src/libcamera/property_ids.yaml\n> +++ b/src/libcamera/property_ids.yaml\n> @@ -398,7 +398,6 @@ controls:\n>          The property can be used to calculate the physical size of the sensor's\n>          pixel array.\n>\n> -\n\nUps :)\n\nIgnore this hunk, it should have gone in the previous, unrelated patch\n\n>    - PixelArrayFullSize:\n>        type: Size\n>        description: |\n> --\n> 2.26.2\n>","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6518A603F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2020 17:12:14 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 06DF8C0011\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2020 15:12:13 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 20 May 2020 17:15:33 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200520151533.ojh22kvaclrleywl@uno.localdomain>","References":"<20200520151019.744345-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200520151019.744345-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: raspberry: Fix segfault in\n\t~RPiCameraData()","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>","X-List-Received-Date":"Wed, 20 May 2020 15:12:14 -0000"}},{"id":4878,"web_url":"https://patchwork.libcamera.org/comment/4878/","msgid":"<20200521002550.GF25474@pendragon.ideasonboard.com>","date":"2020-05-21T00:25:50","subject":"Re: [libcamera-devel] [PATCH] libcamera: raspberry: Fix segfault in\n\t~RPiCameraData()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, May 20, 2020 at 05:10:19PM +0200, Jacopo Mondi wrote:\n> The RPiCameraData class destructor tries to stop its ipa_ instance\n> without making sure it has been initialized.\n> \n> If the RPiCameraData gets destroyed before its ipa_ member is\n> initialized, in example if the sensor initialization fails during the\n\ns/in example/for example/\n\n> match() function. A nullptr dereference segfault is triggered preventing\n\ns/. A/, a/\n\n> a graceful library teardown.\n> \n> Fix this by checking for ipa_ to be initialized before stopping it.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++-\n>  src/libcamera/property_ids.yaml                    | 1 -\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 07ca9f5d7f53..e16a9c7f10d3 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -304,7 +304,8 @@ public:\n>  \t\t}\n>  \n>  \t\t/* Stop the IPA proxy thread. */\n> -\t\tipa_->stop();\n> +\t\tif (ipa_)\n> +\t\t\tipa_->stop();\n>  \t}\n>  \n>  \tvoid frameStarted(uint32_t sequence);\n> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n> index 2ae178a73d52..da4d0bbf329c 100644\n> --- a/src/libcamera/property_ids.yaml\n> +++ b/src/libcamera/property_ids.yaml\n> @@ -398,7 +398,6 @@ controls:\n>          The property can be used to calculate the physical size of the sensor's\n>          pixel array.\n>  \n> -\n\nWith this hunk removed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>    - PixelArrayFullSize:\n>        type: Size\n>        description: |","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC2C6603D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 May 2020 02:26:01 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 196E724D;\n\tThu, 21 May 2020 02:26:01 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DDK+AncI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1590020761;\n\tbh=oK+Bej+OlAhvtfNlkdyQ2y8jJ0Y8Rhrq4k4jax0WDK8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=DDK+AncIxgjQzVIwQbVXHEnJiK3MKnLzMHI71+y37+Dgm0WP4RXbJ7vCIjht6/X6P\n\tVFOC9X9S4iu1w0laHSMONdNnbC4ARVk8ARwb5qe41YvWuWkd3zEqObZv73EAOpfld9\n\tFoNjd4cLVRM6FxsVeKuM21EZY1QJ/XY8LlYw8KBY=","Date":"Thu, 21 May 2020 03:25:50 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200521002550.GF25474@pendragon.ideasonboard.com>","References":"<20200520151019.744345-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200520151019.744345-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: raspberry: Fix segfault in\n\t~RPiCameraData()","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>","X-List-Received-Date":"Thu, 21 May 2020 00:26:02 -0000"}}]