From patchwork Wed Jun 4 13:07:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 23466 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 9422DC3324 for ; Wed, 4 Jun 2025 13:08:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6519D68DCE; Wed, 4 Jun 2025 15:08:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wdbVlFq+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4ED3D68DBF for ; Wed, 4 Jun 2025 15:07:58 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 484C5E9B; Wed, 4 Jun 2025 15:07:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1749042475; bh=QWQ2kK76rVWquzW+ySsOqLsdhZGBy2YrMXigCm1Rr/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wdbVlFq+gLLbKVJDIrfAYrDMzNFoAU5QcCg9zOlS+3nky9/reASnuxbvGp9aMrW43 6gCzj3noqAWm20zDe9MXpgDIGPzLGV1WCpnup+r/hs4+Dpbom59bsdedo7Z4i1Tc5z +K+Ld7tjSwJgc+f4pYau0O/JGPSxu0Nip82ObDUI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Hou Qi , Nicolas Dufresne Subject: [PATCH v2 5/7] gstreamer: Fix leak of GstQuery and GstBufferPool in error path Date: Wed, 4 Jun 2025 16:07:39 +0300 Message-ID: <20250604130741.9228-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250604130741.9228-1-laurent.pinchart@ideasonboard.com> References: <20250604130741.9228-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The gst_libcamera_create_video_pool() function leaks a GstQuery instance and a GstBufferPool instance in an error path. Fix the leaks with g_autoptr(). Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze --- src/gstreamer/gstlibcamerasrc.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 9c0ee491ab63..0be64dd836ca 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -541,9 +541,9 @@ static std::tuple gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad, GstCaps *caps, const GstVideoInfo *info) { - GstQuery *query = NULL; + g_autoptr(GstQuery) query = NULL; + g_autoptr(GstBufferPool) pool = NULL; const gboolean need_pool = true; - GstBufferPool *pool = NULL; /* * Get the peer allocation hints to check if it supports the meta API. @@ -587,8 +587,7 @@ gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad, return { NULL, -EINVAL }; } - gst_query_unref(query); - return { pool, 0 }; + return { reinterpret_cast(g_steal_pointer(&pool)), 0 }; } /* Must be called with stream_lock held. */