From patchwork Tue Jul 22 14:53:34 2025 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: 23900 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 24B28BDCC1 for ; Tue, 22 Jul 2025 14:53:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B8C8A6903C; Tue, 22 Jul 2025 16:53:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QSHHyybT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4176E68F93 for ; Tue, 22 Jul 2025 16:53:37 +0200 (CEST) Received: from pb-laptop.local (185.221.140.39.nat.pool.zt.hu [185.221.140.39]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 89CEE19DC; Tue, 22 Jul 2025 16:52:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753195979; bh=ka+3NVoW1Of/ToelkarOWzft0TkgNeA0lqFRKM1bhlY=; h=From:To:Subject:Date:From; b=QSHHyybTTX7QOXtmfvM1OvwjViRU96qGbhIYnTVk5LjAArEjz8N8cw4kHFqLaaKlr pmIjxnaG8OXIuGbClSdJMPM8ZUOO8QdkcVpgTeNCnqqp+J/NMg9GORLgKLakFVcZlQ 5v/+Vhjm6hOARYlcqn19qzFX8mXX2Fmo0zo38vt0= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder Subject: [PATCH v2] utils: codegen: ipc: Check `ipc_` instead of `isolate_` Date: Tue, 22 Jul 2025 16:53:34 +0200 Message-ID: <20250722145334.1777305-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.50.1 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" Only try to send the "Exit" message if the `ipc_` pointer is non-null. If the constructor fails, then `ipc_` might remain nullptr, which would lead to a nullptr dereference in the destructor. This change also modifies the constructor so that only a valid `IPCPipeUnixSocket` object will be saved into the `ipc_` member, which avoids error messages when `IPCPipeUnixSocket::sendAsync()` is called in the inappropriate state in the destructor. Bug: https://bugs.libcamera.org/show_bug.cgi?id=276 Signed-off-by: Barnabás Pőcze Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- changes in v2: * modify constructor not to save "invalid" IPCPipeUnixSocket into member v1: https://patchwork.libcamera.org/patch/23894/ --- .../libcamera_templates/module_ipa_proxy.cpp.tmpl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.50.1 diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl index 0f87e7976..18b4ab5e5 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl @@ -61,15 +61,16 @@ namespace {{ns}} { return; } - ipc_ = std::make_unique(ipam->path().c_str(), - proxyWorkerPath.c_str()); - if (!ipc_->isConnected()) { + auto ipc = std::make_unique(ipam->path().c_str(), + proxyWorkerPath.c_str()); + if (!ipc->isConnected()) { LOG(IPAProxy, Error) << "Failed to create IPCPipe"; return; } - ipc_->recv.connect(this, &{{proxy_name}}::recvMessage); + ipc->recv.connect(this, &{{proxy_name}}::recvMessage); + ipc_ = std::move(ipc); valid_ = true; return; } @@ -96,7 +97,7 @@ namespace {{ns}} { {{proxy_name}}::~{{proxy_name}}() { - if (isolate_) { + if (ipc_) { IPCMessage::Header header = { static_cast({{cmd_enum_name}}::Exit), seq_++ }; IPCMessage msg(header);