{"id":11550,"url":"https://patchwork.libcamera.org/api/1.1/patches/11550/?format=json","web_url":"https://patchwork.libcamera.org/patch/11550/","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":"<20210311205255.741985-3-nicolas@ndufresne.ca>","date":"2021-03-11T20:52:55","name":"[libcamera-devel,2/2] gst: pool: Fix GstBuffer leak on error","commit_ref":"6795ffe67f3318e474ee14141e5b394b0e5d2d85","pull_url":null,"state":"accepted","archived":false,"hash":"6247c26b62f3a459d0f5ca92d060d341087a161b","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/1.1/people/30/?format=json","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11550/mbox/","series":[{"id":1784,"url":"https://patchwork.libcamera.org/api/1.1/series/1784/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1784","date":"2021-03-11T20:52:53","name":"GStreamer Fixes","version":1,"mbox":"https://patchwork.libcamera.org/series/1784/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11550/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11550/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 3657FBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Mar 2021 20:53:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F2D9468C6D;\n\tThu, 11 Mar 2021 21:53:11 +0100 (CET)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DDF4D602ED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Mar 2021 21:53:10 +0100 (CET)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nicolas) with ESMTPSA id 44BE71F40E90"],"From":"Nicolas Dufresne <nicolas@ndufresne.ca>","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":"<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":"Nicolas Dufresne <nicolas.dufresne@collabora.com>, kernel@collabora.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nWe borrowed a GstBuffer from the pool, if preparing the buffer failed,\nwe need to push it back to avoid leaking it.\n\nSigned-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\n src/gstreamer/gstlibcamerapool.cpp | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)","diff":"diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp\nindex 62db184f..1fde4213 100644\n--- a/src/gstreamer/gstlibcamerapool.cpp\n+++ b/src/gstreamer/gstlibcamerapool.cpp\n@@ -40,8 +40,10 @@ gst_libcamera_pool_acquire_buffer(GstBufferPool *pool, GstBuffer **buffer,\n \tif (!buf)\n \t\treturn GST_FLOW_ERROR;\n \n-\tif (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf))\n+\tif (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf)) {\n+\t\tgst_atomic_queue_push(self->queue, buf);\n \t\treturn GST_FLOW_ERROR;\n+\t}\n \n \t*buffer = buf;\n \treturn GST_FLOW_OK;\n","prefixes":["libcamera-devel","2/2"]}