From patchwork Fri Apr 3 17:31:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26415 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 B75C7BEFBE for ; Fri, 3 Apr 2026 17:31:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E50C762D15; Fri, 3 Apr 2026 19:31:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gL4oDo4Z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2733D62781 for ; Fri, 3 Apr 2026 19:31:10 +0200 (CEST) Received: from pb-laptop.local (185.221.140.112.nat.pool.zt.hu [185.221.140.112]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BFEE122D for ; Fri, 3 Apr 2026 19:29:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775237385; bh=eF1GQxvs58q9gKSPmVxUmuk8bk7n22zHQSx3C+zFwCc=; h=From:To:Subject:Date:From; b=gL4oDo4ZAc/30uI9o6MUFyMNXFo9r8agY10l9N8jLUazr8IQ0zYYmZ0BwE5mnOXKY yWNuIpRoyDfiXR+KgHKsVAOE3J9aZToNQPXz1g3wdffYc06RNVcColozesGvEIlY7p dMccqoS+eLHD1cFjvlbtS9ZF1pRUlDDVd8zJwkyA= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= 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 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" `RkISP1Frames::{clear,destroy}()` always push all buffers from the `RkISP1FrameInfo` object to the corresponding `available*Buffers_` queues. This is not entirely correct. If no dewarper is used, then `availableMainPathBuffers_` is never consumed, so it will grow with each request. Fix it by only queueing the buffer if `RkISP1CameraData::usesDewarper_`. Additionally, in raw capture mode, no parameter or statistics buffers are used, so those queues will be filled up with `nullptr`s without limit. Fix that by only queueing them if they are not null. Fixes: c8f63760e55a ("pipeline: rkisp1: Support raw Bayer capture at runtime") Fixes: 12b553d691d4 ("libcamera: rkisp1: Plumb the dw100 dewarper as V4L2M2M converter") Signed-off-by: Barnabás Pőcze --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index faeeecd96..a8756cefa 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -86,6 +86,8 @@ public: RkISP1FrameInfo *find(Request *request); private: + void recycleBuffers(RkISP1FrameInfo &info); + PipelineHandlerRkISP1 *pipe_; std::map frameInfo_; }; @@ -316,12 +318,7 @@ int RkISP1Frames::destroy(unsigned int frame) if (it == frameInfo_.end()) return -ENOENT; - auto &info = it->second; - - pipe_->availableParamBuffers_.push(info.paramBuffer); - pipe_->availableStatBuffers_.push(info.statBuffer); - pipe_->availableMainPathBuffers_.push(info.mainPathBuffer); - + recycleBuffers(it->second); frameInfo_.erase(it); return 0; @@ -329,13 +326,22 @@ int RkISP1Frames::destroy(unsigned int frame) void RkISP1Frames::clear() { - for (const auto &[frame, info] : frameInfo_) { + for (auto &[frame, info] : frameInfo_) + recycleBuffers(info); + + frameInfo_.clear(); +} + +void RkISP1Frames::recycleBuffers(RkISP1FrameInfo &info) +{ + if (info.paramBuffer) pipe_->availableParamBuffers_.push(info.paramBuffer); + + if (info.statBuffer) pipe_->availableStatBuffers_.push(info.statBuffer); - pipe_->availableMainPathBuffers_.push(info.mainPathBuffer); - } - frameInfo_.clear(); + if (pipe_->cameraData(pipe_->activeCamera_)->usesDewarper_) + pipe_->availableMainPathBuffers_.push(info.mainPathBuffer); } RkISP1FrameInfo *RkISP1Frames::find(unsigned int frame)