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;