{"id":26415,"url":"https://patchwork.libcamera.org/api/1.1/patches/26415/?format=json","web_url":"https://patchwork.libcamera.org/patch/26415/","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":"<20260403173106.473431-1-barnabas.pocze@ideasonboard.com>","date":"2026-04-03T17:31:06","name":"[v1] libcamera: pipeline: rkisp1: Fix buffer queue memleaks","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"a4c570aef0ae17ac0f00052fe8c02e406785e282","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26415/mbox/","series":[{"id":5865,"url":"https://patchwork.libcamera.org/api/1.1/series/5865/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5865","date":"2026-04-03T17:31:06","name":"[v1] libcamera: pipeline: rkisp1: Fix buffer queue memleaks","version":1,"mbox":"https://patchwork.libcamera.org/series/5865/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26415/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26415/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 B75C7BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Apr 2026 17:31:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E50C762D15;\n\tFri,  3 Apr 2026 19:31:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2733D62781\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Apr 2026 19:31:10 +0200 (CEST)","from pb-laptop.local (185.221.140.112.nat.pool.zt.hu\n\t[185.221.140.112])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BFEE122D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Apr 2026 19:29:45 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gL4oDo4Z\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775237385;\n\tbh=eF1GQxvs58q9gKSPmVxUmuk8bk7n22zHQSx3C+zFwCc=;\n\th=From:To:Subject:Date:From;\n\tb=gL4oDo4ZAc/30uI9o6MUFyMNXFo9r8agY10l9N8jLUazr8IQ0zYYmZ0BwE5mnOXKY\n\tyWNuIpRoyDfiXR+KgHKsVAOE3J9aZToNQPXz1g3wdffYc06RNVcColozesGvEIlY7p\n\tdMccqoS+eLHD1cFjvlbtS9ZF1pRUlDDVd8zJwkyA=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v1] libcamera: pipeline: rkisp1: Fix buffer queue memleaks","Date":"Fri,  3 Apr 2026 19:31:06 +0200","Message-ID":"<20260403173106.473431-1-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.53.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"`RkISP1Frames::{clear,destroy}()` always push all buffers from the\n`RkISP1FrameInfo` object to the corresponding `available*Buffers_`\nqueues. This is not entirely correct.\n\nIf no dewarper is used, then `availableMainPathBuffers_` is never\nconsumed, so it will grow with each request. Fix it by only queueing\nthe buffer if `RkISP1CameraData::usesDewarper_`.\n\nAdditionally, in raw capture mode, no parameter or statistics buffers are\nused, so those queues will be filled up with `nullptr`s without limit.\nFix that by only queueing them if they are not null.\n\nFixes: c8f63760e55a (\"pipeline: rkisp1: Support raw Bayer capture at runtime\")\nFixes: 12b553d691d4 (\"libcamera: rkisp1: Plumb the dw100 dewarper as V4L2M2M converter\")\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 26 +++++++++++++++---------\n 1 file changed, 16 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex faeeecd96..a8756cefa 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -86,6 +86,8 @@ public:\n \tRkISP1FrameInfo *find(Request *request);\n \n private:\n+\tvoid recycleBuffers(RkISP1FrameInfo &info);\n+\n \tPipelineHandlerRkISP1 *pipe_;\n \tstd::map<unsigned int, RkISP1FrameInfo> frameInfo_;\n };\n@@ -316,12 +318,7 @@ int RkISP1Frames::destroy(unsigned int frame)\n \tif (it == frameInfo_.end())\n \t\treturn -ENOENT;\n \n-\tauto &info = it->second;\n-\n-\tpipe_->availableParamBuffers_.push(info.paramBuffer);\n-\tpipe_->availableStatBuffers_.push(info.statBuffer);\n-\tpipe_->availableMainPathBuffers_.push(info.mainPathBuffer);\n-\n+\trecycleBuffers(it->second);\n \tframeInfo_.erase(it);\n \n \treturn 0;\n@@ -329,13 +326,22 @@ int RkISP1Frames::destroy(unsigned int frame)\n \n void RkISP1Frames::clear()\n {\n-\tfor (const auto &[frame, info] : frameInfo_) {\n+\tfor (auto &[frame, info] : frameInfo_)\n+\t\trecycleBuffers(info);\n+\n+\tframeInfo_.clear();\n+}\n+\n+void RkISP1Frames::recycleBuffers(RkISP1FrameInfo &info)\n+{\n+\tif (info.paramBuffer)\n \t\tpipe_->availableParamBuffers_.push(info.paramBuffer);\n+\n+\tif (info.statBuffer)\n \t\tpipe_->availableStatBuffers_.push(info.statBuffer);\n-\t\tpipe_->availableMainPathBuffers_.push(info.mainPathBuffer);\n-\t}\n \n-\tframeInfo_.clear();\n+\tif (pipe_->cameraData(pipe_->activeCamera_)->usesDewarper_)\n+\t\tpipe_->availableMainPathBuffers_.push(info.mainPathBuffer);\n }\n \n RkISP1FrameInfo *RkISP1Frames::find(unsigned int frame)\n","prefixes":["v1"]}