From patchwork Thu Mar 11 20:52:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 11549 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 CAF27BD80C for ; Thu, 11 Mar 2021 20:53:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AB6368C6E; Thu, 11 Mar 2021 21:53:09 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D6FF602E8 for ; Thu, 11 Mar 2021 21:53:08 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id AAD891F466FC From: Nicolas Dufresne To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Mar 2021 15:52:54 -0500 Message-Id: <20210311205255.741985-2-nicolas@ndufresne.ca> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210311205255.741985-1-nicolas@ndufresne.ca> References: <20210311205255.741985-1-nicolas@ndufresne.ca> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] gst: provider: Fix crash in finalize 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: Nicolas Dufresne , kernel@collabora.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicolas Dufresne Both the DeviceProvider and Device classes had the same mistake, calling G_OBJECT_GET_CLASS() instead of G_OBJECT_CLASS() when chaining their finalize call to their base class. This would crash at destruction, which was causing gst-device-monitor-1.0 tool to crash and application using that API to crash too. Signed-off-by: Nicolas Dufresne Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/gstreamer/gstlibcameraprovider.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gstreamer/gstlibcameraprovider.cpp b/src/gstreamer/gstlibcameraprovider.cpp index ee44dc73..29da6c32 100644 --- a/src/gstreamer/gstlibcameraprovider.cpp +++ b/src/gstreamer/gstlibcameraprovider.cpp @@ -101,7 +101,7 @@ gst_libcamera_device_finalize(GObject *object) g_free(self->name); - G_OBJECT_GET_CLASS(klass)->finalize(object); + G_OBJECT_CLASS(klass)->finalize(object); } static void @@ -218,7 +218,7 @@ gst_libcamera_provider_finalize(GObject *object) delete self->cm; - return G_OBJECT_GET_CLASS(klass)->finalize(object); + return G_OBJECT_CLASS(klass)->finalize(object); } static void From patchwork Thu Mar 11 20:52:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 11550 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 3657FBD80C for ; Thu, 11 Mar 2021 20:53:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F2D9468C6D; Thu, 11 Mar 2021 21:53:11 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDF4D602ED for ; Thu, 11 Mar 2021 21:53:10 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id 44BE71F40E90 From: Nicolas Dufresne To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Mar 2021 15:52:55 -0500 Message-Id: <20210311205255.741985-3-nicolas@ndufresne.ca> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210311205255.741985-1-nicolas@ndufresne.ca> References: <20210311205255.741985-1-nicolas@ndufresne.ca> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] gst: pool: Fix GstBuffer leak on error 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: Nicolas Dufresne , kernel@collabora.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicolas Dufresne We borrowed a GstBuffer from the pool, if preparing the buffer failed, we need to push it back to avoid leaking it. Signed-off-by: Nicolas Dufresne Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/gstreamer/gstlibcamerapool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp index 62db184f..1fde4213 100644 --- a/src/gstreamer/gstlibcamerapool.cpp +++ b/src/gstreamer/gstlibcamerapool.cpp @@ -40,8 +40,10 @@ gst_libcamera_pool_acquire_buffer(GstBufferPool *pool, GstBuffer **buffer, if (!buf) return GST_FLOW_ERROR; - if (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf)) + if (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf)) { + gst_atomic_queue_push(self->queue, buf); return GST_FLOW_ERROR; + } *buffer = buf; return GST_FLOW_OK;