[{"id":15605,"web_url":"https://patchwork.libcamera.org/comment/15605/","msgid":"<YEqdq6T0lOZelbYe@pendragon.ideasonboard.com>","date":"2021-03-11T22:46:03","subject":"Re: [libcamera-devel] [PATCH 2/2] gst: pool: Fix GstBuffer leak on\n\terror","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nicolas,\n\nThank you for the patch.\n\nOn Thu, Mar 11, 2021 at 03:52:55PM -0500, Nicolas Dufresne wrote:\n> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> \n> We borrowed a GstBuffer from the pool, if preparing the buffer failed,\n> we need to push it back to avoid leaking it.\n> \n> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/gstreamer/gstlibcamerapool.cpp | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp\n> index 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;","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 91472BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Mar 2021 22:46:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1098D602ED;\n\tThu, 11 Mar 2021 23:46:39 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CC041602E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Mar 2021 23:46:37 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3CFB93E4;\n\tThu, 11 Mar 2021 23:46:37 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wh4Rg5VX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1615502797;\n\tbh=Ztn+uMTJyGgAfal7/KnqMtjYSsiqqsypAtHgMsKBENk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wh4Rg5VXk2DAuvuhaWGF7MHKbd14o5mh7j8u4BmGN9x0D0C2XBD+4+3eIrrS7uQQN\n\tC20cxWWKn3GdbR0v23+TDlr/pttmd/LE/7bnZlWj4UgWug2ZjY8ptI71mZ2habU6YL\n\tX0x8+ApMvXk611tkv+HrKi4CyldcTN2vFFmOAxcg=","Date":"Fri, 12 Mar 2021 00:46:03 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nicolas Dufresne <nicolas@ndufresne.ca>","Message-ID":"<YEqdq6T0lOZelbYe@pendragon.ideasonboard.com>","References":"<20210311205255.741985-1-nicolas@ndufresne.ca>\n\t<20210311205255.741985-3-nicolas@ndufresne.ca>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210311205255.741985-3-nicolas@ndufresne.ca>","Subject":"Re: [libcamera-devel] [PATCH 2/2] gst: pool: Fix GstBuffer leak on\n\terror","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, kernel@collabora.com,\n\tNicolas Dufresne <nicolas.dufresne@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>"}},{"id":15608,"web_url":"https://patchwork.libcamera.org/comment/15608/","msgid":"<aee4e2b4-aea2-60da-348a-640368e04451@uajain.com>","date":"2021-03-12T05:08:17","subject":"Re: [libcamera-devel] [PATCH 2/2] gst: pool: Fix GstBuffer leak on\n\terror","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/people/1/","name":"Umang Jain","email":"email@uajain.com"},"content":"Hi Nicolas,\n\nOn 3/12/21 2:22 AM, Nicolas Dufresne wrote:\n> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n>\n> We borrowed a GstBuffer from the pool, if preparing the buffer failed,\n> we need to push it back to avoid leaking it.\n>\n> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\nReviewed-by: Umang Jain <email@uajain.com>\n> ---\n>   src/gstreamer/gstlibcamerapool.cpp | 4 +++-\n>   1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp\n> index 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;","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 28F11BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Mar 2021 05:08:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A0F4760106;\n\tFri, 12 Mar 2021 06:08:22 +0100 (CET)","from mail.uajain.com (static.126.159.217.95.clients.your-server.de\n\t[95.217.159.126])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 05C9F60106\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Mar 2021 06:08:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"DfKxavOv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail;\n\tt=1615525700; bh=GoeMeHuZyYdk2lgH+rh7IOWXKfs0jPZxi2jZFEFCn3U=;\n\th=Subject:To:Cc:References:From:In-Reply-To;\n\tb=DfKxavOv6DDlkeZ+0D7Ycl9Gpoe0/lFv77vty+AZyRhOPyvMuWaMZLHNgNSoN5OlG\n\tCwS5oaYvPBkW0MsD09JTkTPe6JcN9l4o84/CVlGWTcXYFYCN/oaqsyy+FdO/HammC6\n\tMJ5LGgNhDl7IwjxFzNBMOkD5+iUiCFz86KakK38pc66J5RPjY1hJ5O/+jpv8SknDm2\n\tId2yRa2wrQ+Ibjgu6Dasq3lvg4WvmdjKEYXquTTIp6t1erv5D+FVLcexZFrwVFvD6T\n\ttKzhiKRYKkXijXCSvddHtgmZxCdYVuEsdLaSnKpQjviXAIKauxEE6br+jJ5/29ckfu\n\tGm/nmLt9H7Hew==","To":"Nicolas Dufresne <nicolas@ndufresne.ca>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210311205255.741985-1-nicolas@ndufresne.ca>\n\t<20210311205255.741985-3-nicolas@ndufresne.ca>","From":"Umang Jain <email@uajain.com>","Message-ID":"<aee4e2b4-aea2-60da-348a-640368e04451@uajain.com>","Date":"Fri, 12 Mar 2021 10:38:17 +0530","Mime-Version":"1.0","In-Reply-To":"<20210311205255.741985-3-nicolas@ndufresne.ca>","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 2/2] gst: pool: Fix GstBuffer leak on\n\terror","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-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]